- This topic has 2 replies, 3 voices, and was last updated 16 years, 2 months ago by rmcvay.
-
AuthorPosts
-
acuretraMemberI am creating a tiny web application which uses JPA to communicate with the database using Hibernate. I have created the java classes from the database table with the MyEclipse 6.5 reverse engineering tool. This works well.
Now I need to be able to support multiple databases, the actual database being determined at runtime. I understand the way to do this is to pass a map of properties to the EntityManagerFactory to get the EntityManager.
Unfortunately the EntityManagerHelper as generated by MyEclipse 6.5 initializes the EntityManager object in the “static {….}” section meaning that it is done at class load time, so it is practically impossible to alter the behaviour by subclassing or creating the EntityManager object “outside” of EntityManagerHelper. This means that I will have to change the generated class itself, and then these changes will be overwritten next time I do a reverse engineer which is not optimal.
I suggest that since everything goes through getEntityManager() anyway, these fields should not be statically initizalied, but checked for null in getEntityManager() and only if null should be initialized to the default. This allow me to load the class, set the EntityManager externally, and then just go ahead. The persistance unit name should then also be externaly accessible .
Can this be changed for MyEclipse 7.0, please?
/Thorbjørn
Riyad KallaMemberThorbjørn,
While we certainly appreciate the feedback, this is an extreme edge and the first time we’ve ever seen it requested. I can certainly file it in our enhancement tracking system, but the reality of the product management team assigning resources to this work *over* higher priority work is unlikely.
Sorry
rmcvayMemberNow I need to be able to support multiple databases, the actual database being determined at runtime.
(Just an interested bystander) Would you mind expanding on that? Do you mean different instances, different vendors’ databases, different schemas? I’m just not clear on what “multiple databases” means in that context.
-
AuthorPosts