Passing EntityManager reference between methods doesn't work as expected
posted 7 years ago
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.