There is a persistence.xml which links a PersistenceUnit name to a data source name such that when the EntityManager is injected it is tied to the related data source. What I'd like to do and am not sure I can, is keep the single PersistenceUnit name but, programmatically, link it to one of several data sources.
foo1-ds.xml points to logicalDB1a
foo2-ds.xml points to logicalDB1b
foo3-ds.xml points to logicalDB1c
the logicalDB1 series have the precisely identical table structure, just different data. This distinction (having multiple logical databases) is a business requirement. Rather than having, in this case, 3 versions of the program each with a different persistence.xml I'd like one instance of the program that starts with a selection menu for which database this run will be opening. Perhaps a single selection menubox or a radio button selection
and the rest of th3 beans will be identical to if they had but a single data source.
to further elaborate, I am ok with multiple persistent-units defined in the persistence.xml just so long as I can programatically control which one gets mapped to the Seam controller bean entityManager (or em) which logically represents that particular data source. I was hoping the answer would lie in chapter 8 or even 9 but I don't see a solution there.