I have a maven-built CDI-based Java SE app, which has a core module, and other modules.
Core has the persistence.xml
and some entities.
Modules have additional entities.
How can I add the entities to the spotlight of the persistence unit?
I have read Hibernate manual, http://docs.jboss.org/hibernate/stable/entitymanager/reference/en/html/configuration.html#setup-configuration-packaging
I have also seen these SO questions
I am looking for a solution where Hibernate would scan for all loaded classes, or, would pick up some config file form the other jars (like e.g. CDI does with beans.xml
).
My app does not use Spring.
I don't insist on portability - I'll stick with Hibernate.
- Is there some such solution?
- Is there's a way to create a PU from
persistence.xml
and add classes to it programmatically?
- Can I add @Entity classes to
EntityManagerFactory
after it was created?
Update: I found in org.?hibernate.?ejb.?Ejb3Configuration
:
public Ejb3Configuration configure(String persistenceUnitName, Map integration)
http://docs.jboss.org/hibernate/entitymanager/3.6/javadocs/
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…