Reputation: 8135
My code:
emf = Persistence.createEntityManagerFactory("cassandra_pu");
em = emf.createEntityManager();
I change the persistence.xml dynamically to change to IP address of the cassandra_pu unit. However maybe it is executing too fast thus the old entity manager is returned instead of new one. Is there any way to check whether the created em entity manager good enough to use or not?
Upvotes: 2
Views: 99
Reputation: 21165
Some providers allow it but it's native functionality. Check out Eclipselink's refreshMetadata() to pick up changes. But you should be using a new PU if only the database connection/schema is different. Just specify an ORM.xml to override table and scheme names as needed and you can reuse classes
Upvotes: 0
Reputation: 236124
It might depend on the EJB container in use, but in general changes to persistence.xml
won't be reflected until the next redeploy of the application - so the "old" entity manager will be returned over and over again until you redeploy.
Upvotes: 1