我有一個Hibernate一對多單向關聯的問題。休眠一對多單向關聯,從父母選擇孩子?
class Parent{
int id;
set <Child> children;
}
class Child{
int id;
int name;
int birthday;
}
Parent.hbm.xml
<hibernate-mapping>
<class name="Parent" table="parent"/>
<id name="id" column="id_parent"/>
<set name="children" inverse="false" cascade="all">
<key column="id_parent"/>
<one-to-many class="Child"/>
</set>
</hibernate-mapping>
Child.hbm.xml
<hibernate-mapping>
<class name="Child" table="parent"/>
<id name="id" column="id_child"/>
<property = "birthday"/>
<property="name"/>
</hibernate-mapping>
在映射文件
,我使用一個一對多關聯單向通過設置逆=」假」。
如何選擇正確的孩子與他的名字,生日和家長身份信息?
最好的問候 謝謝!
Parent.children如何映射? –
你想要做什麼?找到一個有給定的父母,給定的名字和給定的生日的孩子? –
是的,正是我的意思 – lhuang