In a web application using struts2 ejb hibernate, is it possible to tell the application to find or create an entity for a specific persistence-unit name, which is written in persistence.xml file, in the deployment time?
I have two persistence-unit in persistence.xml, and one datasource
(including two “local-tx-datasource”) xml file under the jboss node.
To clearify, I mean, I tried this;
@Entity
@PersistenceContext(unitName="MY JNDI NAME specified in persistence.xml")
public abstract class Vehicle {
and doesnt work.. Then tried this and etc..
@PersistenceContext(name="MY PERSISTENCE UNIT NAME specified in persistence.xml")
@PersistenceUnit(name="MY PERSISTENCE UNIT NAME specified in persistence.xml")
and also I tried these above with the “UnitName=..” instead of “name=..” but anything is worked for me…
[SOLVED]
<.exclude-unlisted-classes>true<./exclude-unlisted-classes>
has solved my problem
Update: Based on your comment (this is not what I understood from the original question), I don’t think you have any other option than disabling “discovery” and listing explicitly your entities in their respective persistence unit:
I’m not aware of any syntax at the entity level allowing to assign it to a persistence unit.
I’m not sure I understood what you’re trying to do but if you want to get an Entity Manager for a specific persistence unit injected, you should do:If this is not what you want, please clarify the question.