• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • 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:
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic