首页 > 代码库 > hibernate单对多(onetomany)准确设置级注意事项

hibernate单对多(onetomany)准确设置级注意事项

Baen属性

One.java

private List<Many> manyList = new ArrayList<Many>();

Many.java

private One oneId;

hbm.xml

ont.hbm.xml
<list name="manyList" cascade="all">
			<key column="one_id" ></key>
			<index column="id" />
            <one-to-many class="com.wondersgroup.mchis.wom.entity.Many"/>
		</list>

many.hbm.xml
<many-to-one name="oneId" class="com.wondersgroup.mchis.wom.entity.One" column="one_id"></many-to-one>


使用Set、List参考文章

http://kdboy.iteye.com/blog/573035

hibernate单对多(onetomany)准确设置级注意事项