现在有个关联问题总是生成不出表格,总是提示关联出错
我把代码贴出来,请高手看看是什么问题

解决方案 »

  1.   

    package com.hibernate.bean;import java.io.Serializable;
    import java.util.*;
    public class CpStoreroom implements Serializable {
    /**
     * 
     */
    private static final long serialVersionUID = 1L;
    public CpStoreroom(){

    }

    // primary key
    private Integer roomId;
    /* fields*/
    private String roomName;
    private Integer storeDesc;
    private String memo;
    //设置排架实体
    private Set <CpStoreStructure> cpStoreStructure = new HashSet<CpStoreStructure>();
    /***
     * 得到排架
     * @return
     */
    public Set<CpStoreStructure> getCpStoreStructure() {
    return cpStoreStructure;
    }
    /***
     * 设置排架
     * @param cpStoreStructure
     */
    public void setCpStoreStructure(Set<CpStoreStructure> cpStoreStructure) {
    this.cpStoreStructure = cpStoreStructure;
    }
    /***
     * 获得库房ID
     * @return
     */
    public java.lang.Integer getRoomId() {
    return roomId;
    }
    /***
     * 设置库房ID
     * @param roomId
     */
    public void setRoomId(int roomId) {
    this.roomId = roomId;
    }
    /***
     * 获得库房名称
     * @return
     */
    public java.lang.String getRoomName() {
    return roomName;
    }
    /***
     * 设置库房名称
     * @param roomName
     */
    public void setRoomName(String roomName) {
    this.roomName = roomName;
    }
    /***
     * 得到库房排序
     * @return
     */
    public java.lang.Integer getStoreDesc() {
    return storeDesc;
    }
    /***
     * 设置库房排序
     * @param storeDesc
     */
    public void setStoreDesc(int storeDesc) {
    this.storeDesc = storeDesc;
    }

    /***
     * 得到库房备注
     * @return
     */
    public String getMemo() {
    return memo;
    }
    /***
     * 设置库房备注
     * @param memo
     */
    public void setMemo(String memo) {
    this.memo = memo;
    } }
      

  2.   

    <?xml version="1.0" encoding="utf-8"?>
    <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"><hibernate-mapping>
    <class name="com.hibernate.bean.CpStoreroom" table="CP_STOREROOM"
    lazy="false">
    <id name="roomId" type="java.lang.Integer" column="roomId">
    <generator class="assigned" />
    </id>
    <property name="roomName" type="java.lang.String">
    <column name="roomName" length="32" />
    </property>
    <property name="storeDesc" type="java.lang.Integer">
    <column name="storeDesc" length="32" />
    </property> <property name="memo" type="java.lang.String">
    <column name="Memo" length="256" />
    </property> <!-- <set name="cpStoreStructure" inverse="false" lazy="false" cascade="all"> 
    <key> <column name="tacticId" scale="0" /> </key> <one-to-many class="com.hibernate.bean.CpStoreStructure" 
    /> </set> --> <set name="cpStoreStructure" inverse="true" lazy="false" cascade="all">
    <key>
    <column name="tacticId" />
    </key>
    <one-to-many class="com.hibernate.bean.CpStoreStructure" />
    </set>


    </class>
    </hibernate-mapping>
      

  3.   

    package com.hibernate.bean;import java.io.Serializable;
    /***
     * 排架信息
     * @author wan
     *
     */
    public class CpStoreStructure implements Serializable {
    /**
     * 
     */
    private static final long serialVersionUID = 1L;
    // primary key
    private Integer tacticId;
    // fields
    private String tacticName;
    private Integer tacticOrder;
    private String memo;
    private CpStoreroom cpStoreroom;
    /***
     * 获得库房
     * @return
     */
    public CpStoreroom getCpStoreroom() {
    return cpStoreroom;
    }

    /***
     * 设置库房
     * @param cpStoreroom
     */ public void setCpStoreroom(CpStoreroom cpStoreroom) {
    this.cpStoreroom = cpStoreroom;
    } /***
     * 得到排架ID
     * 
     * @return int
     */
    public java.lang.Integer getTacticId() {
    return tacticId;
    } /***
     * 设置排架ID
     * 
     * @param tacticId
     */
    public void setTacticId(java.lang.Integer tacticId) {
    this.tacticId = tacticId;
    } /***
     * 获得排架名称
     * 
     * @return
     */
    public java.lang.String getTacticName() {
    return tacticName;
    } /***
     * 设置排架名称
     * 
     * @param tacticName
     */
    public void setTacticName(java.lang.String tacticName) {
    this.tacticName = tacticName;
    } /***
     * 获得排架序号
     * 
     * @return
     */
    public java.lang.Integer getTacticOrder() {
    return tacticOrder;
    } /***
     * 设置排架序号
     * 
     * @param tacticOrder
     */
    public void setTacticOrder(java.lang.Integer tacticOrder) {
    this.tacticOrder = tacticOrder;
    } /***
     * 得到备注
     * 
     * @return
     */
    public java.lang.String getMemo() {
    return memo;
    } /***
     * 获得备注
     * 
     * @param memo
     */
    public void setMemo(java.lang.String memo) {
    this.memo = memo;
    }}