• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Passing EntityManager reference between methods doesn't work as expected

 
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I apologize in advance for a lengthy post but I guess I need to support my query with code.

I am coding for a system which has 12 database instances. All databases have the same number and name of tables but the data is different (of course:)). Depending on a URL parameter passed from an external application, I need to choose one of the 12 databases at runtime.
I have coded a EntityFactory wrapper which takes in the URL parameter and returns an appropriate EntityManager instance using Reflection.
Problem is that the returned EntityManager, when used in find, is not loading the Entity attributes as it should. Not surprisingly, find works inside the EntityFactory wrapper.

Main class:


Persistence.xml snippet:
reply
    Bookmark Topic Watch Topic
  • New Topic