• Post Reply Bookmark Topic Watch Topic
  • New Topic

Passing EntityManager reference between methods doesn't work as expected

a sarkar
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
  • 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:
Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!