3

由于某种原因,hibernate 没有捕捉到诸如将实体映射到不存在的表之类的问题。我的 persistence.xml 文件看起来像这样......

<?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_1_0.xsd" version="1.0">

    <!-- A JPA Persistence Unit -->
    <persistence-unit name="printLogixJpaUnit" transaction-type="RESOURCE_LOCAL">
        <provider>org.hibernate.ejb.HibernatePersistence</provider>

        <class>com.printlogix.rp.server.domain.User</class>
        <class>com.printlogix.rp.server.domain.UserImage</class>
        <class>com.printlogix.rp.server.domain.TemplateInstance</class>
        <class>com.printlogix.rp.server.domain.UserOrder</class>
        <class>com.printlogix.rp.server.domain.OrderLineItem</class>
        <class>com.printlogix.rp.server.domain.OrderStatus</class>
        <class>com.printlogix.rp.server.domain.AgencyImage</class>
        <class>com.printlogix.rp.server.domain.Agency</class>
        <class>com.printlogix.rp.server.domain.Brokerage</class>
        <class>com.printlogix.rp.server.domain.SystemTemplate</class>
        <class>com.printlogix.rp.server.domain.TemplateType</class>
        <class>com.printlogix.rp.server.domain.Product</class>
        <class>com.printlogix.rp.server.domain.ProductDefinition</class>
        <class>com.printlogix.rp.server.domain.ExpeditedAddress</class>
        <class>com.printlogix.rp.server.domain.BrokerageUser</class>
        <class>com.printlogix.rp.server.domain.StateProvince</class>
        <class>com.printlogix.rp.server.domain.Country</class>
        <class>com.printlogix.rp.server.domain.AwardClub</class>
        <class>com.printlogix.rp.server.domain.SuperUser</class>
        <class>com.printlogix.rp.server.domain.AgencyUser</class>
        <class>com.printlogix.rp.server.domain.RememberMe</class>
        <class>com.printlogix.rp.server.domain.PasswordResetRequest</class>
        <class>com.printlogix.rp.server.domain.SystemTheme</class>
        <exclude-unlisted-classes>true</exclude-unlisted-classes>

        <properties>
            <property name="hibernate.show_sql" value="true"/>
            <!--Begin Credentials -->
            <property name="hibernate.connection.url" value="jdbc:mysql://localhost/realtorprint_dev?autoReconnect=true"/>
            <property name="hibernate.connection.username" value="test"/>
            <property name="hibernate.connection.password" value="test"/>
            <!--End Credentials -->
            <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
            <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect"/>
        </properties>
    </persistence-unit>

</persistence>
4

1 回答 1

10

尝试添加值为“validate”的属性“hibernate.hbm2ddl.auto”:

<property name="hibernate.hbm2ddl.auto" value="validate"/>
于 2011-09-15T23:27:54.637 回答