Note that there are some explanatory texts on larger screens.

plurals
  1. POJPA 2.0: Adding entity classes to PersistenceUnit *from different jar* automatically
    primarykey
    data
    text
    <p>I have a maven-built CDI-based Java SE app, which has a <em>core</em> module, and other modules.<br> Core has the <code>persistence.xml</code> and some entities. Modules have additional entities.</p> <p>How can I add the entities to the spotlight of the persistence unit?</p> <p>I have read Hibernate manual, <a href="http://docs.jboss.org/hibernate/stable/entitymanager/reference/en/html/configuration.html#setup-configuration-packaging" rel="noreferrer">http://docs.jboss.org/hibernate/stable/entitymanager/reference/en/html/configuration.html#setup-configuration-packaging</a></p> <p>I have also seen these SO questions</p> <ul> <li><a href="https://stackoverflow.com/questions/1211777/how-can-i-merge-extend-persistence-units-from-different-jars">How can I merge / extend persistence units from different JARs?</a></li> <li><a href="https://stackoverflow.com/questions/3774663/define-jpa-entity-classes-outside-of-persistence-xml">define jpa entity classes outside of persistence.xml</a></li> <li><a href="https://stackoverflow.com/questions/2838634/programmatically-loading-entity-classes-with-jpa-2-0">Programmatically loading Entity classes with JPA 2.0?</a></li> </ul> <p>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 <code>beans.xml</code>). </p> <p>My app does not use Spring. I don't insist on portability - I'll stick with Hibernate.</p> <ul> <li><strong>Is there some such solution?</strong></li> <li><strong>Is there's a way to create a PU from <code>persistence.xml</code> and add classes to it programmatically?</strong></li> <li><strong>Can I add @Entity classes to <code>EntityManagerFactory</code> after it was created?</strong></li> </ul> <hr> <p><em>Update:</em> I found in <code>org.​hibernate.​ejb.​Ejb3Configuration</code>: </p> <pre><code>public Ejb3Configuration configure(String persistenceUnitName, Map integration) </code></pre> <p><a href="http://docs.jboss.org/hibernate/entitymanager/3.6/javadocs/" rel="noreferrer">http://docs.jboss.org/hibernate/entitymanager/3.6/javadocs/</a></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload