hibernate one2many (双向关联)
2021-05-17 13:29
阅读:690
标签:oct hiberna hbm.xml turn hbm return ide pen blog
跟单向关联仅有几处不同:
1从多的一方加入新的属性
package com.cnblogs.hibernate_first; public class Student { private int id; private String name; private Classes classes; public Classes getClasses() { return classes; } public void setClasses(Classes classes) { this.classes = classes; } public int getId() { return id; } public void setId(int id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } }
2修改xml文件.Classes.hbm.xml
span>mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd" >package="com.cnblogs.hibernate_first"> class name="Classes" table="t_classes"> class="native"> class> class="com.cnblogs.hibernate_first.Student"/>
3,修改Student.hbm.xml文件
span>mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd" >package="com.cnblogs.hibernate_first"> class name="Student" table="t_student"> class="native"> class>
hibernate one2many (双向关联)
标签:oct hiberna hbm.xml turn hbm return ide pen blog
原文地址:http://www.cnblogs.com/Juli/p/7743954.html
评论
亲,登录后才可以留言!