facebook

Generated EntityManagerHelper for JPA is inflexible

  1. MyEclipse Archived
  2.  > 
  3. Database Tools (DB Explorer, Hibernate, etc.)
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #290149 Reply

    acuretra
    Member

    I 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

    #290197 Reply

    Riyad Kalla
    Member

    Thorbjø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

    #290200 Reply

    rmcvay
    Member

    Now 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.

Viewing 3 posts - 1 through 3 (of 3 total)
Reply To: Generated EntityManagerHelper for JPA is inflexible

You must be logged in to post in the forum log in