- 浏览: 646693 次
- 性别:
- 来自: 常州
文章分类
- 全部博客 (345)
- java (63)
- Struts2 (11)
- Spring2.5 + (17)
- Hibernate (25)
- Struts2 Spring hibernate (5)
- log4j (3)
- apache tomcat (12)
- oracle (22)
- oracle_存储过程 (4)
- mysql (18)
- jquery (11)
- prototype (5)
- js (19)
- quartz (5)
- 设计模式 (6)
- eclipse/MyEclipse 注意事项 (9)
- eclipse (0)
- css (6)
- 正则表达式 (2)
- linux (18)
- PHP (6)
- 多线程 (20)
- XML (1)
- jstl (3)
- mongoDB (7)
- android (20)
- 反射 (1)
- IOS (46)
- SVN (3)
- C/C++ (4)
- 百度地图 (2)
- IO/SOCKET (3)
- 百度地图JS (1)
- 树莓派/香蕉派 (1)
最新评论
-
anny101:
想转发一下,不知道怎么转发。评论一下吧。方便查看。
fetch = FetchType.EAGER 作用 -
Navee:
果然我这也是是防火墙问题
解决 Linux 安装 httpd局域网无法访问 -
dhyang909:
...
oracle 10g+ 行列转换 -
国产希特勒:
真强,居然有人把公司的面试题挂到javaeye上了
锦江国际的一道面试题(很简单) -
tomfish88:
比如我要拦截不同业务的service类里面的方法 @Poi ...
Spring AOP annotation 拦截表达式 分析
package com.hibernate.entity; import java.io.Serializable; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; @Entity public class Student implements Serializable { /** * */ private static final long serialVersionUID = 3543286868313801941L; private int id; private String name; // private Set<Teacher> teachers = new HashSet<Teacher>(); @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; } // @ManyToMany // public Set<Teacher> getTeachers() { // return teachers; // } // // public void setTeachers(Set<Teacher> teachers) { // this.teachers = teachers; // } }
package com.hibernate.entity; import java.io.Serializable; import java.util.HashSet; import java.util.Set; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.JoinTable; import javax.persistence.ManyToMany; @Entity public class Teacher implements Serializable { /** * */ private static final long serialVersionUID = 3543286868313801941L; private int id; private String name; private Set<Student> students = new HashSet<Student>(); @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; } @ManyToMany @JoinTable( name="s_t", joinColumns= @JoinColumn(name="teacherid", referencedColumnName="id"),//当前表里的id inverseJoinColumns= @JoinColumn(name="studentid", referencedColumnName="id")//与此相对应的表里的id ) public Set<Student> getStudents() { return students; } public void setStudents(Set<Student> students) { this.students = students; } }
hibernate.cfg.xml和ORMappingTest与之前一样,拷过来就可以使用
当然,.xml中要加
<mapping class="com.hibernate.entity.Teacher" /> <mapping class="com.hibernate.entity.Student" />
发表评论
-
OneToMany字段序列化 failed to lazily initialize a collection of role
2014-06-06 18:51 1462hibernate项目中,如果要对onetomany的po ... -
hibernate 本地查询 字段别名 映射到 DTO时注意事项
2014-04-22 13:54 3506本地原生SQL: SELECT pole.pId as ... -
实体中的数据库字段有关键字
2014-03-26 15:08 984mysql中如果表的字段设成了关键字,那么在做某些操作时会抛 ... -
Spring +hibernate 声明式 事物 + annotation
2012-03-22 19:49 912在applicationContext.xml中 &l ... -
Hibernate distinct
2012-02-15 18:05 1069/** * 得到大区编号和名称 * @ret ... -
@Transactional 事务回滚 分析
2011-11-08 16:51 4282@Transactional 事务回滚 Spring的 ... -
Hibernate 性能优化_3
2011-10-25 15:54 608二级缓存 对于二级缓存,其实并不一定要在项目中使用 ... -
Hibernate 性能优化_2
2011-10-20 17:51 827createQuery("FROM ****&quo ... -
Hibernate 性能优化_1
2011-10-18 18:39 968大概如此:不一定说在每个项目中都合适 1、 使用se ... -
Hibernate 的 Criteria用法,完整的一个例子
2011-10-18 16:49 1112数据库: /* MySQL Data Transfer ... -
转的:Hibernate 的 Criteria用法
2011-10-18 16:37 1302方法 说明 Restric ... -
Hibernate 的 join
2011-10-18 13:29 978转的: 1.如果没有在Hibernate配置里做关 ... -
fetch = FetchType.EAGER 作用
2011-10-13 11:47 28704如果是EAGER,那么表示取出这条数据时,它关联的数据也同时取 ... -
用myeclipse的Hibernate 反向引擎 生成 数据库的 entity
2011-09-22 14:44 8806把 Myeclipse 转到DB Browser 新建 ... -
Hibernate annotation 多对多双向关联(很少用)
2011-09-21 16:44 1675双向关联 在认为的 主表 上用到 @JoinTable ... -
Hibernate annotation 一对多,多对一
2011-09-21 16:03 1940package com.hibernate.entity ... -
Hibernate annotation 联合主键
2011-09-20 15:31 1527Hibernate annotation 联合主键 ... -
Hibernate annotation 的各种关系
2011-09-15 15:59 995转的: 一、@OneToOne Java ... -
Hibernate 双向关联
2011-09-15 15:55 976不管是啥关联,只要是双向,都必须用到mappedBy ... -
OneToOne annotation 双向关联
2011-09-15 15:51 1163package com.hibernate.entity ...
相关推荐
NULL 博文链接:https://paladin1988.iteye.com/blog/1634669
NULL 博文链接:https://paladin1988.iteye.com/blog/1633417
和其它许多批注一样,在多对多关联中很多值是自动生成,党双向多对多关联中没有定义任何物理映射时,Hibernate根据以下规则生成相应的值,关联表名:主表表名+下划线+从表表名,关联到主表的外键名:主表名+下划线+...
NULL 博文链接:https://cdxs2.iteye.com/blog/1932868
NULL 博文链接:https://cdxs2.iteye.com/blog/1932861
NULL 博文链接:https://cdxs2.iteye.com/blog/1932864
NULL 博文链接:https://cdxs2.iteye.com/blog/1932507
NULL 博文链接:https://cdxs2.iteye.com/blog/1930748
12.4.5 多对一单向关联的annotation注解实现538 12.4.6 一对多双向关联的annotation注解实现540 12.4.7 一对多双向自身关联的annotation注解实现542 12.4.8 多对多单向关联的annotation注解实现543 12.4.9 多对多...
7.3. 使用连接表的单向关联(Unidirectional associations with join tables) 7.3.1. 一对多(one to many) 7.3.2. 多对一(many to one) 7.3.3. 一对一(one to one) 7.3.4. 多对多(many to many) 7.4. ...
7.3. 使用连接表的单向关联(Unidirectional associations with join tables) 7.3.1. 一对多(one to many) 7.3.2. 多对一(many to one) 7.3.3. 一对一(one to one) 7.3.4. 多对多(many to many) 7.4. ...
7.3. 使用连接表的单向关联(Unidirectional associations with join tables) 7.3.1. 一对多(one to many) 7.3.2. 多对一(many to one) 7.3.3. 一对一(one to one) 7.3.4. 多对多(many to many) 7.4. ...
7.3. 使用连接表的单向关联(Unidirectional associations with join tables) 7.3.1. 一对多(one to many) 7.3.2. 多对一(many to one) 7.3.3. 一对一(one to one) 7.3.4. 多对多(many to many) 7.4. ...
7.3. 使用连接表的单向关联(Unidirectional associations with join tables) 7.3.1. 一对多(one to many) 7.3.2. 多对一(many to one) 7.3.3. 一对一(one to one) 7.3.4. 多对多(many to many) 7.4. 双向...
使用连接表的单向关联(Unidirectional associations with join tables) 7.3.1. 一对多(one to many) 7.3.2. 多对一(many to one) 7.3.3. 一对一(one to one) 7.3.4. 多对多(many to many) 7.4. 双向...
7.3. 使用连接表的单向关联(Unidirectional associations with join tables) 7.3.1. 一对多(one to many) 7.3.2. 多对一(many to one) 7.3.3. 一对一(one to one) 7.3.4. 多对多(many to many) 7.4. 双向...
8.3. 使用连接表的单向关联(Unidirectional associations with join tables) 8.3.1. 一对多(one to many) 8.3.2. 多对一(many to one) 8.3.3. 一对一(one to one) 8.3.4. 多对多(many to many) 8.4. ...
7.3. 使用连接表的单向关联(Unidirectional associations with join tables) 7.3.1. 一对多(one to many) 7.3.2. 多对一(many to one) 7.3.3. 一对一(one to one) 7.3.4. 多对多(many to many) 7.4. ...
这种策略支持双向的一对多关联,但不支持 IDENTIFY 生成器策略,因为ID必须在多个表间共享。一旦使用就不能使用AUTO和IDENTIFY生成器。 每个类层次结构一张表 @Entity @Inheritance(strategy=InheritanceType....
8.3. 使用连接表的单向关联(Unidirectional associations with join tables) 8.3.1. 一对多(one to many) 8.3.2. 多对一(many to one) 8.3.3. 一对一(one to one) 8.3.4. 多对多(many to many) 8.4. ...