neo
neo

Reputation: 2471

JPA - don't want to hard code unitName in @PersistenceContext

I am using eclipselink and I have something like this:

@PersistenceContext(unitName = "unit1")
private EntityManager em;

Is there any way that I can specify/read the persistent unit name from a config/property file so that if I want, i can change the persistent unit name (so that it will point to a different data source)?

Upvotes: 2

Views: 609

Answers (1)

James
James

Reputation: 18379

Don't use injection, lookup the context in code.

Upvotes: 0

Related Questions