hibernate 联合查询fetch
来源:互联网 发布:巨灵新闻数据库 编辑:程序博客网 时间:2024/06/01 10:17
@Entity
public class Student {
private int id;
private Teacher teacher;
private CommonProperty commonProperty;//组件中有两个实体类属性
public CommonProperty getCommonProperty() {
return commonProperty;
}
public void setCommonProperty(CommonProperty commonProperty) {
this.commonProperty = commonProperty;
}
@Id
@GeneratedValue
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
@ManyToOne(cascade = CascadeType.ALL,fetch=FetchType.LAZY)//多对一中多短
@JoinColumn(name="teacher_id")
public Teacher getTeacher() {
return teacher;
}
public void setTeacher(Teacher teacher) {
this.teacher = teacher;
}
}
实体类 teacher
@Entity
public class Teacher {
private int id;
private CommonProperty commonProperty;
private List <Student> students;
private String title;
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
@Id
@GeneratedValue
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public CommonProperty getCommonProperty() {//组件中有两个实体类属性
return commonProperty;
}
public void setCommonProperty(CommonProperty commonProperty) {
this.commonProperty = commonProperty;
}
@OneToMany(cascade = CascadeType.ALL,mappedBy="teacher",fetch=FetchType.EAGER )//一对多的一端
public List<Student> getStudents() {
return students;
}
public void setStudents(List<Student> students) {
this.students = students;
}
}
l=session.createQuery("from Student a inner join fetch a.teacher").list();//使用了fetch,意思是把Student对应的Teacher实体类放到Student类中的属性teacher中。list中就是student实体类
- hibernate 联合查询fetch
- hibernate 内查询 fetch
- hibernate 内查询 fetch
- Hibernate联合查询
- hibernate 联合主键查询
- hibernate多表联合查询
- hibernate引用查询和联合查询
- Hibernate联合主键 以及根据联合主键中字段查询
- hibernate fetch
- hibernate fetch
- Hibernate---fetch
- Hibernate多表联合查询解决办法
- Hibernate多表联合查询解决办法
- hibernate的多表联合查询
- Hibernate多表联合查询结果处理
- spring+hibernate 多表的联合查询
- Hibernate中的联合查询【图片来源于:转载】
- hibernate映射文件不支持union联合查询
- 批处理,%~d0 cd %~dp0 代表什么意思
- HP ALM 使用经验
- Lapka:iPhone专用的多功能环境监测器
- Application does not specify an API level requirement!
- HDU 1597 find the nth digit
- hibernate 联合查询fetch
- 离散Hilbert变换的一些说明
- linux 开发程序过程 vim
- 寻找丑数
- Xen Cloud Platform 系列:XenCenter 安装
- VS2010的智能提示没有了的可能原因
- linux chkconfig 使用说明
- C无符号数和有符号数探讨
- ZOJ 1151 Word Reversal