Have you tried the unitName attribute?
yes i tried. but i got an exception:
Field javax.persistence.EntityManager QMoDIS.backend.BussinessTier.session.SessionObjektAuswahl.em @PersistenceUnit in error: EMPTY STRING unitName and there is more than one scoped persistence unit
That's the problem, because i have more than one persistence-Unit.
i want to extend the persistence context for all possible persistence-contexts, that may be injected.
What value did you provide for unitName? Was it a value from your persistence.xml file?
<persistence-unit name="someDB"> ... </persistence-unit>
I think this is the way it's done anyway. Personally, I use SMPC.
An SMPC is equivalent to an extended persistence context for conversationally scoped components.
i have more than one persistence unit defined in persistence.xml, because i'am using more than one database.
But for all possible units i have defined in the persistence.xml i must have an extended persistence context.
is there a way to define the extension of the persistence contexts directly in the persistence.xml instead of annotating this behaviour at the entitymanager definition?
i used SMPC(for example):
<core:managed-persistence-context name="myManagername" auto-create="true" persistence-unit-jndi-name="java:/myjndiname"> </core:managed-persistence-context>
but the context is not extended, because
in the code i get the ref to the Entitymanger i described further, but the Dataselection Model will not work in my stateful session beans, so it's not extended.
Seam bijection depends on variable name. Try this:
@In(create=true) private EntityManager myManagername;
the problem is that the name of the entitymanager will be determined at runtime. so i can't put the static variable name before runtime in my code.
Not sure why it needs to be determined at runtime but have you tried:
EntityManager em = (EntityManager)Component.getInstance(someRuntimeString, true);
yes. look at my first posting ;)
but if i inititialize the Entitymanager on that way(in some SFSB) the DataSelection Model will not work properly. It works only if in Annotate the Entitymanager Variable with @PersistenceContext(unit-name"myunitname", type=PersistenceContextType.EXTENDED).
But then i must hardcode a unit-name, and thats the problem.
it's needed at runtime, because, every EntityManager has a binding to a database and which Database will be used, is decided at runtime.
i define the Entitymanager on that way:
EntityManager em = (EntityManager)Component.getInstance(someRuntimeString);
Without the second Parameter set on true. maybe thats the problem ?