Note that there are some explanatory texts on larger screens.

plurals
  1. POSpring LocalContainerEntityManagerFactoryBean scanForPackages and Hibernate package-level type definitions
    primarykey
    data
    text
    <p>In Spring 3.1 and higher the <a href="http://static.springsource.org/spring/docs/3.1.x/javadoc-api/org/springframework/orm/jpa/LocalContainerEntityManagerFactoryBean.html" rel="noreferrer">LocalContainerEntityManagerFactoryBean</a> is supposed to be able to configure the JPA EntityManagerFactory without a persistence.xml. The configuration is included in the bean definition for LocalContainerEntityManagerFactoryBean instead.</p> <p>When I use the packagesToScan method to tell the factory bean where to scan for my entity classes it doesn't seem to be picking up my <a href="http://docs.jboss.org/hibernate/orm/4.1/manual/en-US/html_single/#d5e2957" rel="noreferrer">Hibernate type definitions</a> which are defined at the package level.</p> <p>package-info.java:</p> <pre><code>@org.hibernate.annotations.TypeDefs({ @org.hibernate.annotations.TypeDef(name = "TypeA", typeClass = com.foo.type.A.class), @org.hibernate.annotations.TypeDef(name = "TypeB", typeClass = com.foo.type.B.class) }) package com.foo.type; </code></pre> <p>spring-jpa.xml:</p> <pre><code> &lt;bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean" lazy-init="true"&gt; &lt;property name="dataSource" ref="dataSource" /&gt; &lt;property name="persistenceProviderClass" value="org.hibernate.ejb.HibernatePersistence"/&gt; &lt;property name="jpaVendorAdapter"&gt; &lt;bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter" /&gt; &lt;/property&gt; &lt;property name="jpaPropertyMap"&gt; &lt;map&gt; &lt;entry key="hibernate.dialect" value="com.foo.FooDialect" /&gt; &lt;entry key="hibernate.default_schema" value="dba"/&gt; &lt;entry key="hibernate.cache.use_query_cache" value="false"/&gt; &lt;entry key="hibernate.cache.use_second_level_cache" value="true"/&gt; &lt;entry key="hibernate.cache.region.factory_class" value="org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory"/&gt; &lt;entry key="net.sf.ehcache.configurationResourceName" value="META-INF/ehcache.xml" /&gt; &lt;entry key="javax.persistence.validation.factory" value-ref="validator"/&gt; &lt;/map&gt; &lt;/property&gt; &lt;property name="packagesToScan"&gt; &lt;list&gt; &lt;value&gt;com.foo.domain&lt;/value&gt; &lt;value&gt;com.foo.type&lt;/value&gt; &lt;/list&gt; &lt;/property&gt; &lt;/bean&gt; </code></pre> <p>Is there a way to make this work?</p>
    singulars
    1. This table or related slice is empty.
    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.
    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