3 Replies Latest reply on May 12, 2006 11:26 AM by geoff74

    Get entity manager without annotation?

    Geoffrey Mitchell Newbie

      I want to be able to persist the same entities on different entity managers based on a runtime discriminator (different databases/schemas with the same table structure for different orginizational entities). I can do this by using:

      @PersistenceContext(name="x", unitName="x")
      @PersistenceContext(name="y", unitName="y")

      then looking up the context I want by name. What I want, though, is to be able to configure the available persistence contexts in a common place, so I don't have to list the available contexts in every session bean I reference them from. Since injection is only performed on bean classes, I can't delegate this to a helper class. Since the @PersistenceContext annotation is not inherited, I can't use a base class to provide the functionality.

      Do I have any options? Is there some way I can say "make these entity managers available from JNDI to everything in my EAR"? I've been through the spec, and didn't see anything that seemed to give me what I wanted.

      Does what I am trying to do make sense? Is there another approach in common use?

      Any input would be appreciated.