in my application which uses EclipseLink 1.1.1 I'd like to change database at runtime.
The reason is this: on MySQL server there are several databases with identical structure. Decission which database use is made in application at runtime and it may change during the application lifecycle.
Is the only solution to have one persistent unit for each database?
You could either have a different persistence unit for each database.
Or you could have a single persistence unit, but create a different EntityManagerFactory for each database. You would pass a properties into the createEntityManagerFactory, and give the new url for the database.
I have one more question. When I try to create EntityManager with properties Map Eclipselink creates it, but it is the same as the first one. It seems like there is some cache. Maybe there is some property that needs to be set. Any help appreciated.