Hibernate的list中出现null值的情况

两个类如下:

public class Item implements java.io.Serializable {

	// Fields

	private Long iid;
	private Template template;
	private Long showOrder;
                ................................
}

 

public class Template implements java.io.Serializable {

	// Fields

	private Long tid;
	private String name;
	private String gtype;
	private Date createTime;
	private List items = new ArrayList();
                ..................................
}

 配置文件如下:

<hibernate-mapping>
    <class name="Item" table="ITEM" >
        <id name="iid" type="java.lang.Long">
            <column name="IID" precision="22" scale="0" />
            <generator class="increment" />
        </id>
        <many-to-one name="template" class="Template" fetch="select">
            <column name="TID" precision="22" scale="0" />
        </many-to-one>
        <property name="showOrder" type="java.lang.Long">
            <column name="SHOW_ORDER" precision="22" scale="0" not-null="true" />
        </property>
    </class>
</hibernate-mapping>

 

<hibernate-mapping>
    <class name="Template" table="TEMPLATE">
        <id name="tid" type="java.lang.Long">
            <column name="TID" precision="22" scale="0" />
            <generator class="increment" />
        </id>
        <property name="name" type="java.lang.String">
            <column name="NAME" length="100" not-null="true" />
        </property>
        <property name="gtype" type="java.lang.String">
            <column name="GTYPE" length="1" not-null="true" />
        </property>
        <property name="createTime" type="java.util.Date">
            <column name="CREATE_TIME" length="7" />
        </property>
        <list name="items" inverse="true" cascade="all">
            <key>
                <column name="TID" precision="22" scale="0" not-null="true"/>
            </key>
            <list-index column="SHOW_ORDER"></list-index>
            <one-to-many class="Item" />
        </list>
    </class>
</hibernate-mapping>

 Template取得items属性时,list里会包含null值,不知道什么原因

你可能感兴趣的:(java,html,Hibernate,Blog)