hibernate不能自动生成表的原因总结

时间:2022-01-01 11:59:42

1. upate-》create

<property name="hbm2ddl.auto">create</property>

 

2. 2.Mapping的映射文件有重名的,如:

<mapping resource="com/runsky/domain/Status.hbm.xml" />
<mapping resource="com/runsky/domain/Status.hbm.xml" />

 3.表中有关键字,如:
order,level,address,degree等。

4.在配置文件中不小心写了两个同名属性,如:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="org.hibernate.auction">

    <class name="com.runsky.domain.AdditionalInformation"
        table="AdditionalInformation" lazy="false">
            <id name="id" column ="ID" length="32">
                <generator class="uuid.hex"/>
            </id>
            <property name="tag" column ="tag" />
            <property name="content" column ="content" />
                <property name="id" column ="id" />   
    </class>
</hibernate-mapping>

 5.全类名写错了

6. 自增长字段是String类型, 应该改成Long