【发布时间】:2014-06-23 16:18:34
【问题描述】:
我正在尝试使用以下配置为 hibernate 4.3 和 JPA 和 Spring 4 配置测试:
<bean id="em" class="LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter" />
</property>
<property name="persistenceXmlLocation"
value="classpath:integrations/hibernate4/jpa/persistence.xml" />
</bean>
现在持久化配置如下所示:
<persistence-unit name="test" >
<class>hibernate4.jpa.JpaEntity</class>
<class>hibernate4.jpa.JpaHiLoEntity</class>
<properties>
<property name="hibernate.hbm2ddl.auto" value="create" />
</properties>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
</persistence-unit>
如果我使用 hibernate 4.2.4 运行上述程序,一切运行正常,但是使用 4.3 时,上述设置会加载所有 hbm.xml 资源文件,其中一些引用类路径中不存在的类,从而导致 ClassNotFoundException。
有谁知道改变行为的原因是什么以及如何阻止休眠扫描 hbm.xml 文件(packagesToScan 属性也不起作用)?
【问题讨论】: