2

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)?

neo
  • 2,461
  • 9
  • 42
  • 67
  • 1
    Do you have more than one persistent unit in your configuration file? If not you can just remove the `unitName` – Anthony Accioly Apr 29 '11 at 20:24
  • Similar question http://stackoverflow.com/questions/5104185/how-to-inject-persistence-context-to-different-data-source-programmatically/5280608#5280608 – Nayan Wadekar Apr 30 '11 at 09:11

1 Answers1

0

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

James
  • 17,965
  • 11
  • 91
  • 146