Pau*_*gas 22
您需要添加到persistence.xml下一行:
<exclude-unlisted-classes>false</exclude-unlisted-classes>
例如
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" ...>
    <persistence-unit name="YourPU" ...>
        <exclude-unlisted-classes>false</exclude-unlisted-classes>
        <properties>
            <property name="eclipselink.logging.level" value="ALL"/>
            <property name="eclipselink.ddl-generation" 
                value="drop-and-create-tables"/>
        </properties>
    </persistence-unit>
</persistence>
从Spring 3.1开始,您还可以选择完全忘记persistence.xml,并EntityManagerFactory使用该packagesToScan属性进行配置,类似于:
<bean id="entityManagerFactory" 
      class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
      p:dataSource-ref="dataSource"
      p:packagesToScan="${jpa.entity.packages}">
    <property name="jpaVendorAdapter">
        <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"
              p:showSql="${hibernate.show_sql}"/>
    </property>
    <property name="jpaProperties">
        <props>
            <prop key="hibernate.format_sql">${hibernate.format_sql}</prop>
            <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
        </props>
    </property>
</bean>
| 归档时间: | 
 | 
| 查看次数: | 17484 次 | 
| 最近记录: |