- 浏览: 67640 次
- 性别:
文章分类
最新评论
package com.bjsxt.hibernate; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.ManyToOne; import javax.persistence.Table; @Entity @Table(name="t_user") public class User { private int id; private String name; private Group group; @ManyToOne public Group getGroup() { return group; } public void setGroup(Group group) { this.group = group; } @Id @GeneratedValue 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; } }
package com.bjsxt.hibernate; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.Table; @Entity @Table(name="t_group") public class Group { private int id; private String name; @Id @GeneratedValue 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; } }
<?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <hibernate-mapping> <class name="com.bjsxt.hibernate.User" table="t_user"> <id name="id"> <generator class="native"></generator> </id> <property name="name"></property> <many-to-one name="group" column="groupId" /> </class> </hibernate-mapping>
<?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <hibernate-mapping> <class name="com.bjsxt.hibernate.Group" table="t_group"> <id name="id"> <generator class="native"></generator> </id> <property name="name"></property> </class> </hibernate-mapping>
发表评论
-
22.hibernate继承映射joined
2011-12-07 18:14 754person表结构: teacher表结构: studen ... -
21.hibernate继承映射table_per_class
2011-12-07 18:14 991t_gen_table表结构: person表结构: te ... -
20.hibernate继承映射single_table
2011-11-25 12:17 825单个表: person表结构如下: package co ... -
19.hibernate多对多双向关联
2011-11-25 12:17 726package com.bjsxt.hibernate; ... -
18.hibernate多对多单向关联
2011-11-25 12:17 712package com.bjsxt.hibernate; ... -
17.hibernate一对多,多对一双向关联
2011-11-25 12:17 909package com.bjsxt.hibernate; ... -
16.hibernate一对多单向关联
2011-11-25 12:16 716package com.bjsxt.hibernate; ... -
14.hibernate 一对一component(组合),jpa映射
2011-11-24 00:48 1082只存在一个表: husband表结构: package ... -
13.hibernate一对一单向联合主键外键关联,jpa映射
2011-11-24 00:47 1557husband表结构: wife表结构: packag ... -
12.hibernate一对一双向主键关联,jpa映射
2011-11-24 00:47 986husband表结构: wife表结构: pack ... -
11.hibernate一对一双向主键关联,xml映射
2011-11-24 00:46 774student表结构: stuidcard表结构 ... -
10.hibernate一对一单向主键关联,jpa映射
2011-11-23 19:43 1455husband表结构: wife表结构: pac ... -
9.hibernate一对一单向主键关联,xml映射
2011-11-23 19:42 916student表结构: stuidcard表结构 pa ... -
8.hibernate一对一双向外键关联,jpa映射
2011-11-23 19:42 857husband表结构: wife表结构 packa ... -
7.hibernate一对一双向外键关联,xml映射
2011-11-23 19:41 872stuidcard表结构: student表结构: ... -
6.hibernate一对一单向外键关联,jpa映射
2011-11-23 19:40 1667husband表结构: wife表结构 package ... -
5.hibernate一对一单向外键关联,xml映射
2011-11-21 18:25 424stuidcard表结构: student表结构: p ... -
4.hibernate联合主键,jpa映射
2011-11-21 18:17 927package com.bjsxt.hibernate; ... -
3.hibernate联合主键,xml映射
2011-11-21 18:13 957package com.bjsxt.hibernate; ... -
2.hibernate 枚举类型, 布尔类型,不持久化属性映射
2011-11-21 18:06 1380package com.bjsxt.hibernate; ...
相关推荐
这里包含了hibernate多对一单向关联关系实现源码,希望对你有用。
多对多单向关联 <br>需要注意映射规则: <set name="users" table="t_user_role"><br> <key column="roleid"/><br> <many-to-many class="com.bjsxt.hibernate.User" column="userid"/> </set>
hibernate主键实现一对一单向关联关系源码
Hibernate 多对一外键单向关联 Hibernate 多对一连接表单向关联 Hibernate 多对多单向关联 Hibernate 一对一外键双向关联 Hibernate 一对一主键双向关联 Hibernate 一对一连接表双向关联 Hibernate 一对多外键双向...
hibernate关联映射注解多对多单向关联、
hibernate外键实现一对一单向关联关系源码
Hibernate学习:单向多对一关联 工程
多对多双向关联 <br>注意映射规则: <set name="roles" table="t_user_role"><br> <key column="userid"/><br> <many-to-many class="com.bjsxt.hibernate.Role" column="roleid"/> </set><br> table...
hibernate单向一对多关联映射(注解版)
Hibernate 一对多 外键 单向关联,有例子。
包含《多对多双向关联映射》《多对一单向关联映射》《多对一双向关联映射》《一对多单向关联映射》等文档,并有图解及例子,非常适合新手学习,尤其是刚刚接触hibernate,对映射关系不清楚的。。。。
NULL 博文链接:https://ganshisheng.iteye.com/blog/434420
博文链接:https://shaqiang32.iteye.com/blog/201308
│ ├─ 多对一外键单向关联 │ ├─ 多对一连接表单向关联 │ └─ 多对多单向关联 └─双向关联 ├─ 一对一外键双向关联 ├─ 一对一主键双向关联 ├─ 一对一连接表双向关联 ├─ 一对多外键双向关联 ├─ 一对...
博文链接:https://shaqiang32.iteye.com/blog/201314
博文链接:https://llying.iteye.com/blog/220809
NULL 博文链接:https://paladin1988.iteye.com/blog/1627597