Note that there are some explanatory texts on larger screens.

plurals
  1. POusing the MergingPersistenceUnitManager to load entity
    primarykey
    data
    text
    <p>I have a project setup where i have a module which is present in the WEB-INF/lib folder of the parent war file. This module contains a persistence.xml and an entity which i need to be loaded when the JPA container loads during startup. Somehow i need to merge the persistence units of the war and the lib jar. the persistence.xml of my war is present in WEB-INF/classes/META-INF hence it would take WEB-INF/classes as the persistence root and wouldnt understand the entity from my lib jar. That i found out the hard way. </p> <p>I stumbled across multiple people suggesting solutions to this problem </p> <p><a href="http://ancientprogramming.blogspot.com/2007/05/multiple-persistencexml-files-and.html" rel="nofollow">http://ancientprogramming.blogspot.com/2007/05/multiple-persistencexml-files-and.html</a> And i also found out that there is Spring's Data-jpa project which has a MergingPersistenceUnitManager which will merge the class definitions of the entities. </p> <p>Here is my configuration </p> <pre><code>&lt;bean id="pum" class="org.springframework.data.jpa.support.MergingPersistenceUnitManager"&gt; &lt;property name="persistenceXmlLocations"&gt; &lt;list&gt; &lt;value&gt;classpath*:META-INF/persistence.xml&lt;/value&gt; &lt;/list&gt; &lt;/property&gt; &lt;property name="defaultDataSource" ref="dataSource"&gt;&lt;/property&gt; &lt;/bean&gt; &lt;bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"&gt; &lt;property name="dataSource" ref="dataSource" /&gt; &lt;property name="persistenceUnitName" value="LineManagement" /&gt; &lt;property name="persistenceUnitManager" ref="pum"&gt;&lt;/property&gt; &lt;property name="jpaVendorAdapter"&gt; &lt;bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"&gt; &lt;property name="generateDdl" value="false" /&gt; &lt;property name="showSql" value="false" /&gt; &lt;property name="databasePlatform" ref="cpsHibernateDialectClassName" /&gt; &lt;/bean&gt; &lt;/property&gt; </code></pre> <p>which doesnt work. It gives me an error <code>java.lang.NoSuchMethodError:org.springframework.data.jpa.support.MergingPersistenceUnitManager.getPersistenceUnitInfo(Ljava/lang/String;)Lorg/springframework/orm/jpa/persistenceunit/MutablePersistenceUnitInfo;</code></p> <p>I have no clue how it gives me this error. From my understanding the MergingPersistenceUnitManager extends the DefaultPersistenceManager. Only thing i suspect is that there might be a conflict. </p> <p>Here are my dependencies. spring-orm-3.0.2-RELEASE.jar and spring-data-jpa-1.0.3-RELEASE.jar.</p> <p>I can go back to the ancient programming solution, but shouldnt it just work out of the box?</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.
    1. This table or related slice is empty.
    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