Note that there are some explanatory texts on larger screens.

plurals
  1. POremove the uses of <class> tag in persistence.xml hibernate
    text
    copied!<p>I have a demo project on Spring 3.1.1 Hibernate 4.1.1 jsf 2.1.6</p> <p>*<strong>PLEASE IGNORE ANY WHITESPACES AFTER thE START OF "&lt;" IN A TAG : *</strong></p> <p>In the persistance.xml file, I am using the Configuration like the following :</p> <hr/> <blockquote> <p>&lt; ?xml version="1.0" encoding="UTF-8"?><br/> &lt; persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0"></p> </blockquote> <pre><code>&lt;persistence-unit name="app-persistance" transaction-type="RESOURCE_LOCAL"&gt; &lt;provider&gt;org.hibernate.ejb.HibernatePersistence&lt;/provider&gt; &lt;!-- ********* HAS Entries ********* --&gt; &lt;class&gt;com.myapp.domain.classA&lt;/class&gt; &lt;class&gt;com.myapp.domain.classB&lt;/class&gt; &lt;!-- ******More Domain classes here ***--&gt; </code></pre> <blockquote> <p>&lt; /persistence-unit></p> <p>&lt; /persistence></p> </blockquote> <p>And My applicationContext.xml snipeshot is below :</p> <hr/> <blockquote> <p>&lt; bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean" scope="singleton"><br/></p> </blockquote> <pre><code> &lt;property name="persistenceUnitName" value="app-persistance" /&gt; &lt;property name="dataSource" ref="dataSource" /&gt; &lt;property name="jpaProperties"&gt; &lt;props&gt; &lt;prop key="hibernate.dialect"&gt;${hibernate.dialect}&lt;/prop&gt; &lt;prop key="hibernate.hbm2ddl.auto"&gt;${hibernate.hbm2ddl.auto}&lt;/prop&gt; &lt;prop key="hibernate.show_sql"&gt;${hibernate.show_sql}&lt;/prop&gt; &lt;prop key="javax.persistence.validation.mode"&gt;none&lt;/prop&gt; &lt;prop key="javax.persistence.sharedCache.mode"&gt;all&lt;/prop&gt; &lt;prop key="hibernate.search.default.directory_provider"&gt;org.hibernate.search.store.impl.FSDirectoryProvider &lt;/prop&gt; &lt;prop key="hibernate.search.default.indexBase"&gt;c:/lucene/indexes&lt;/prop&gt; &lt;/props&gt; &lt;/property&gt; &lt;/bean&gt; &lt;bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager" scope="singleton"&gt; &lt;property name="entityManagerFactory" ref="entityManagerFactory" /&gt; &lt;/bean&gt; </code></pre> <p>Now, Everytime I Create a any Domain Class, I have to put an entry into persistence.xml All classes are properly annoted.</p> <p>Snipeshot of a domain class :</p> <blockquote> <p>*<strong>imports here *</strong><br/> @Indexed <br/> @Entity <br/> @Table(name = "USER")<br/> @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)<br/> public abstract class User implements Serializable {<br/> @Id<br/> @DocumentId<br/> @Column(name = "ID", length = 20)<br/> @Field(index = Index.YES)<br/> private String id;<br/> ................<br/> .................<br/> }</p> </blockquote> <p><strong>What should be done so that any new domain classes created, persistence.xml tag entry would'nt be required and SQL table gets automatically created in DB</strong></p> <p>since i have already added the following in applicationContext.xml</p> <blockquote> <p>&lt; prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto} &lt; /prop></p> <p>&lt; prop key="hibernate.show_sql">${hibernate.show_sql} &lt; /prop></p> </blockquote>
 

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