为什么我被迫在persistence.xml中列出实体类?

时间:2013-12-05 04:18:23

标签: hibernate jpa persistence.xml

TomEE 1.6 JPA 2.0 Hibernate 2.4.8 MySQL。

设置为false的

exclude-unlisted-classes不应强制我列出实体。

如果没有<class>com.acme.Person</class>,我会收到'未知实体com.acme.Person'。谁知道为什么?

<?xml version="1.0" encoding="UTF-8"?>
    <persistence xmlns="http://java.sun.com/xml/ns/persistence"
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                 xsi:schemaLocation="http://java.sun.com/xml/ns/persistence 
                      http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
     version="2.0">

<persistence-unit name="default" transaction-type="JTA">
    <provider>org.hibernate.ejb.HibernatePersistence</provider>
    <class>com.acme.Person</class>
    <exclude-unlisted-classes>false</exclude-unlisted-classes>

    <properties>
        <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />
        ...

        <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
        <property name="hibernate.show_sql" value="true" />
        <property name="hibernate.hbm2ddl.auto" value="create" />
    </properties>

</persistence-unit>

0 个答案:

没有答案