Hello,
In Eclipse I'm having a web application (call it W) and a separate project(call it P) added to it as a J2EE module dependencie.
So P.jar goes finally into WEB-INF/lib of my web app W.
In W i have a persistence unit (called "inclasses") represented by
- some @entity classes: A and B (who will go in WEB-INF/classes),
- a persistence.xml file (who will go in WEB-INF/classes/META-INF)
- and some DAOs having @PersistenceContext.
In P i have a persistence unit (called "injar") represented by
- some @entity classes: C and D (who will go in WEB-INF/lib/P.jar),
- a persistence.xml file (who will go in WEB-INF/lib/P.jar/META-INF)
In both persistence.xml i have a <provider> pointing at Hibernate.
I made some experiments with my DAOs giving them different unitName:
- "inclasses"
- "injar"
- no unitName specified
In the first case it takes into account A and B and also the inner configuration of persistence.xml found in /classes/META-INF
In the second case it takes into account C and D BUT not the inner configuration of persistence.xml found in /lib/p.jar/META-INF. It takes the default TopLink provider and the default datasource of Glassfish (the datasource for derby on port 1527)
Finally in the las case it cannot deploy saying that several persistence units exist and it does not know which to choose.
I'm on Glassfish 2.1
Question; what is the normal behaviour in this case of strucuture of my war?
Pls. send me to some doc which explains this well.
Also what would happen if both persistence.xml would have the same name: let's say "idem".
PS: i already read the EJB3.0 persistence spec about the # syntax, but that is not about my case.
[Message sent by forum member 'vladbalan' (vladbalan)]
http://forums.java.net/jive/thread.jspa?messageID=356310