好的,根本原因是我对集合的映射无效。感谢这篇关于复合映射的文章
错误:
<key> <column name="ID" /></key>
正确
<many-to-one name="parent" lazy="false" column="PARENT" /><set name="children" lazy="false" fetch="join" table="PRODUCT" cascade="all"> <key> <column name="PARENT" /> </key> <one-to-many /></set>
完整的映射
<class name="Product" table="PRODUCT"> <id name="id" type="java.lang.Long" column="ID"> <generator > <param name="sequence">PRODUCT_SN</param> </generator> </id> <many-to-one name="parent" lazy="false" column="PARENT" /> <set name="children" lazy="false" fetch="join" table="PRODUCT" cascade="all"> <key> <column name="PARENT" /> </key> <one-to-many /> </set> <property name="pre" type="java.lang.String" column="CODE" not-null="true" /> <property name="name" type="java.lang.String" column="NAME" /> <property name="startDate" type="java.util.Date" column="STARTDATE" /> <property name="endDate" type="java.util.Date" column="ENDDATE" /> <property name="decisionable" type="boolean" column="ISDECISIONABLE" /> <property name="selectable" type="boolean" column="ISSELECTABLE" /> </class>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)