日期:2014-05-19  浏览次数:20710 次

使用hibernate不能自动生成表结构,
用的S2SH集合开发一个很简单的项目,Oracle11g
我想用hibernate自动帮我生成4个表结构,person,orders,category,books,但只有前三个生成成功,books没有生成。
XML code
<property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</prop>
                <prop key="hibernate.hbm2ddl.auto">update</prop>
                <prop key="hibernate.show_sql">true</prop>
                <prop key="hibernate.format_sql">true</prop>
            </props>
        </property>
                <property name="mappingResources">
            <list>
                <value>cn/java/ORM/Person.hbm.xml</value>
                <value>cn/java/ORM/Category.hbm.xml</value>
                <value>cn/java/ORM/Orders.hbm.xml</value>
                <value>cn/java/ORM/Books.hbm.xml</value>
            </list>
        </property>




books.java
Java code
public class Books {
    private int id;
    private String name;
    private int money;
    private int inventory;// 库存量
    private int buyQuantity;// 买入量
    private String comment;// 评论
    private Person person;//收藏字段
    private Category category;//种类字段
    private Orders orders;//订单字段

    public Books() {

    }

还有setter,getter方法。没贴
books.hbm.xml
XML code
<hibernate-mapping package="cn.java.ORM">
    <class name="Books" table="BOOKS" lazy="true">
        <id name="id">
            <generator class="sequence" />
        </id>
        <property name="name" />
        <property name="money" />
        <property name="inventory" />
        <property name="buyQuantity" />
        <property name="comment" />
        <!-- 对应 ID字段用于收藏 -->
        <many-to-one name="person" column="person_id" class="Person" />
        <!-- 用于分种类 -->
        <many-to-one name="category" column="category_id" class="Category" />
        <!-- 用于下订单(购物车) -->
        <many-to-one name="orders" column="orders_id" class="Orders" />
    </class>

</hibernate-mapping>




------解决方案--------------------
<prop key="hibernate.hbm2ddl.auto">update</prop>
 好像这个地方要改下吧。记不清了。