(九)Hibernate 检索策略
所有项目导入对应的hibernate的jar包、mysql的jar包和添加每次都需要用到的HibernateUtil.java
这里的hibernate.cfg.xml配置信息我就不再写了
第一节:检索策略属性Lazy
Lazy:true (默认) 延迟检索;set 端一对多
Lazy:false 立即检索;set 端一对多
Lazy:extra 增强延迟检索; set 端一对多
Lazy:proxy(默认) 延迟检索;many-to-one 多对一
Lazy:no-proxy 无代理延迟检索;many-to-one 多对一(需要编译时字节码增强)
Lazy:true (默认) 延迟检索;set 端一对多
Class.java
package com.wishwzp.model; import java.util.HashSet;
import java.util.Set; public class Class { private long id;
private String name;
private Set<Student> students=new HashSet<Student>(); public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Set<Student> getStudents() {
return students;
}
public void setStudents(Set<Student> students) {
this.students = students;
} }
Student.java
package com.wishwzp.model;
public class Student {
private long id;
private String name;
private Class c;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Class getC() {
return c;
}
public void setC(Class c) {
this.c = c;
}
@Override
public String toString() {
return "Student [id=" + id + ", name=" + name + "]";
}
}
Class.hbm.xml
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> <hibernate-mapping package="com.wishwzp.model"> <class name="Class" table="t_class">
<id name="id" column="classId">
<generator class="native"></generator>
</id> <property name="name" column="className"></property> <set name="students" cascade="delete" inverse="true" lazy="true">
<key column="classId"></key>
<one-to-many class="com.wishwzp.model.Student"/>
</set>
</class> </hibernate-mapping>
Student.hbm.xml
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> <hibernate-mapping package="com.wishwzp.model"> <class name="Student" table="t_student">
<id name="id" column="stuId">
<generator class="native"></generator>
</id> <property name="name" column="stuName"></property> <many-to-one name="c" column="classId" class="com.wishwzp.model.Class" cascade="save-update"></many-to-one>
</class> </hibernate-mapping>
StudentTest.java
package com.wishwzp.service; import java.util.Iterator;
import java.util.List;
import java.util.Set; import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.junit.After;
import org.junit.Before;
import org.junit.Test; import com.wishwzp.model.Class;
import com.wishwzp.model.Student;
import com.wishwzp.util.HibernateUtil; public class StudentTest { private SessionFactory sessionFactory=HibernateUtil.getSessionFactory();
private Session session; @Before
public void setUp() throws Exception {
session=sessionFactory.openSession(); // 生成一个session
session.beginTransaction(); // 开启事务
} @After
public void tearDown() throws Exception {
session.getTransaction().commit(); // 提交事务
session.close(); // 关闭session
} @Test
public void testLazy1() {
Class c=(Class)session.get(Class.class, Long.valueOf(1));
Set<Student> studentList=(Set<Student>)c.getStudents();
studentList.iterator();
}
}
数据库里面的信息数据:



运行显示结果:
Hibernate: select class0_.classId as classId1_0_0_, class0_.className as classNam2_0_0_ from t_class class0_ where class0_.classId=?
Hibernate: select students0_.classId as classId3_0_0_, students0_.stuId as stuId1_1_0_, students0_.stuId as stuId1_1_1_, students0_.stuName as stuName2_1_1_, students0_.classId as classId3_1_1_ from t_student students0_ where students0_.classId=?
Lazy:false 立即检索;set 端一对多
Class.hbm.xml
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> <hibernate-mapping package="com.wishwzp.model"> <class name="Class" table="t_class">
<id name="id" column="classId">
<generator class="native"></generator>
</id> <property name="name" column="className"></property> <set name="students" cascade="delete" inverse="true" lazy="false">
<key column="classId"></key>
<one-to-many class="com.wishwzp.model.Student"/>
</set>
</class> </hibernate-mapping>
StudentTest.java
package com.wishwzp.service; import java.util.Iterator;
import java.util.List;
import java.util.Set; import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.junit.After;
import org.junit.Before;
import org.junit.Test; import com.wishwzp.model.Class;
import com.wishwzp.model.Student;
import com.wishwzp.util.HibernateUtil; public class StudentTest { private SessionFactory sessionFactory=HibernateUtil.getSessionFactory();
private Session session; @Before
public void setUp() throws Exception {
session=sessionFactory.openSession(); // 生成一个session
session.beginTransaction(); // 开启事务
} @After
public void tearDown() throws Exception {
session.getTransaction().commit(); // 提交事务
session.close(); // 关闭session
} @Test
public void testLazy1() {
Class c=(Class)session.get(Class.class, Long.valueOf(1)); } }
还是上面第一个的数据库信息。
运行显示结果:
Hibernate: select class0_.classId as classId1_0_0_, class0_.className as classNam2_0_0_ from t_class class0_ where class0_.classId=?
Hibernate: select students0_.classId as classId3_0_0_, students0_.stuId as stuId1_1_0_, students0_.stuId as stuId1_1_1_, students0_.stuName as stuName2_1_1_, students0_.classId as classId3_1_1_ from t_student students0_ where students0_.classId=?
Lazy:extra 增强延迟检索; set 端一对多
Class.hbm.xml
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> <hibernate-mapping package="com.wishwzp.model"> <class name="Class" table="t_class">
<id name="id" column="classId">
<generator class="native"></generator>
</id> <property name="name" column="className"></property> <set name="students" cascade="delete" inverse="true" lazy="extra">
<key column="classId"></key>
<one-to-many class="com.wishwzp.model.Student"/>
</set>
</class> </hibernate-mapping>
StudentTest.java
package com.wishwzp.service; import java.util.Iterator;
import java.util.List;
import java.util.Set; import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.junit.After;
import org.junit.Before;
import org.junit.Test; import com.wishwzp.model.Class;
import com.wishwzp.model.Student;
import com.wishwzp.util.HibernateUtil; public class StudentTest { private SessionFactory sessionFactory=HibernateUtil.getSessionFactory();
private Session session; @Before
public void setUp() throws Exception {
session=sessionFactory.openSession(); // 生成一个session
session.beginTransaction(); // 开启事务
} @After
public void tearDown() throws Exception {
session.getTransaction().commit(); // 提交事务
session.close(); // 关闭session
} @Test
public void testLazy1() {
Class c=(Class)session.get(Class.class, Long.valueOf(1));
Set<Student> studentList=(Set<Student>)c.getStudents();
System.out.println(studentList.size());
} }
还是上面第一个的数据库信息。
运行结果显示:
Hibernate: select class0_.classId as classId1_0_0_, class0_.className as classNam2_0_0_ from t_class class0_ where class0_.classId=?
Hibernate: select count(stuId) from t_student where classId =?
3
Lazy:proxy(默认) 延迟检索;many-to-one 多对一
Student.hbm.xml
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> <hibernate-mapping package="com.wishwzp.model"> <class name="Student" table="t_student">
<id name="id" column="stuId">
<generator class="native"></generator>
</id> <property name="name" column="stuName"></property> <many-to-one name="c" column="classId" class="com.wishwzp.model.Class" cascade="save-update" lazy="proxy"></many-to-one>
</class> </hibernate-mapping>
StudentTest.java
package com.wishwzp.service; import java.util.Iterator;
import java.util.List;
import java.util.Set; import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.junit.After;
import org.junit.Before;
import org.junit.Test; import com.wishwzp.model.Class;
import com.wishwzp.model.Student;
import com.wishwzp.util.HibernateUtil; public class StudentTest { private SessionFactory sessionFactory=HibernateUtil.getSessionFactory();
private Session session; @Before
public void setUp() throws Exception {
session=sessionFactory.openSession(); // 生成一个session
session.beginTransaction(); // 开启事务
} @After
public void tearDown() throws Exception {
session.getTransaction().commit(); // 提交事务
session.close(); // 关闭session
} @Test
public void testLazy2() {
Student student=(Student)session.get(Student.class, Long.valueOf(1));
student.getC().getName();
} }
运行显示结果:
Hibernate: select student0_.stuId as stuId1_1_0_, student0_.stuName as stuName2_1_0_, student0_.classId as classId3_1_0_ from t_student student0_ where student0_.stuId=?
Hibernate: select class0_.classId as classId1_0_0_, class0_.className as classNam2_0_0_ from t_class class0_ where class0_.classId=?
Lazy:no-proxy 无代理延迟检索;many-to-one 多对一(需要编译时字节码增强)
Student.hbm.xml
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> <hibernate-mapping package="com.wishwzp.model"> <class name="Student" table="t_student">
<id name="id" column="stuId">
<generator class="native"></generator>
</id> <property name="name" column="stuName"></property> <many-to-one name="c" column="classId" class="com.wishwzp.model.Class" cascade="save-update" lazy="no-proxy"></many-to-one>
</class> </hibernate-mapping>
StudentTest.java和上面一样
第二节:检索策略属性batch-size
1,批量延迟检索;
2,批量立即检索;
1,批量延迟检索;
Class.hbm.xml
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> <hibernate-mapping package="com.wishwzp.model"> <class name="Class" table="t_class">
<id name="id" column="classId">
<generator class="native"></generator>
</id> <property name="name" column="className"></property> <set name="students" cascade="delete" inverse="true" lazy="true" batch-size="3">
<key column="classId"></key>
<one-to-many class="com.wishwzp.model.Student"/>
</set>
</class> </hibernate-mapping>
StudentTest.java
package com.wishwzp.service; import java.util.Iterator;
import java.util.List;
import java.util.Set; import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.junit.After;
import org.junit.Before;
import org.junit.Test; import com.wishwzp.model.Class;
import com.wishwzp.model.Student;
import com.wishwzp.util.HibernateUtil; public class StudentTest { private SessionFactory sessionFactory=HibernateUtil.getSessionFactory();
private Session session; @Before
public void setUp() throws Exception {
session=sessionFactory.openSession(); // 生成一个session
session.beginTransaction(); // 开启事务
} @After
public void tearDown() throws Exception {
session.getTransaction().commit(); // 提交事务
session.close(); // 关闭session
} @Test
public void testBatch1(){
List<Class> classList=session.createQuery("from Class").list();
Iterator it=classList.iterator();
Class c1=(Class)it.next();
Class c2=(Class)it.next();
Class c3=(Class)it.next();
c1.getStudents().iterator();
c2.getStudents().iterator();
c3.getStudents().iterator();
} }
数据库多加了一条信息:

运行结果显示:
Hibernate: select class0_.classId as classId1_0_, class0_.className as classNam2_0_ from t_class class0_
Hibernate: select students0_.classId as classId3_0_1_, students0_.stuId as stuId1_1_1_, students0_.stuId as stuId1_1_0_, students0_.stuName as stuName2_1_0_, students0_.classId as classId3_1_0_ from t_student students0_ where students0_.classId in (?, ?, ?)
2,批量立即检索;
Class.hbm.xml
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> <hibernate-mapping package="com.wishwzp.model"> <class name="Class" table="t_class">
<id name="id" column="classId">
<generator class="native"></generator>
</id> <property name="name" column="className"></property> <set name="students" cascade="delete" inverse="true" lazy="false" batch-size="3">
<key column="classId"></key>
<one-to-many class="com.wishwzp.model.Student"/>
</set>
</class> </hibernate-mapping>
StudentTest.java
package com.wishwzp.service; import java.util.Iterator;
import java.util.List;
import java.util.Set; import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.junit.After;
import org.junit.Before;
import org.junit.Test; import com.wishwzp.model.Class;
import com.wishwzp.model.Student;
import com.wishwzp.util.HibernateUtil; public class StudentTest { private SessionFactory sessionFactory=HibernateUtil.getSessionFactory();
private Session session; @Before
public void setUp() throws Exception {
session=sessionFactory.openSession(); // 生成一个session
session.beginTransaction(); // 开启事务
} @After
public void tearDown() throws Exception {
session.getTransaction().commit(); // 提交事务
session.close(); // 关闭session
} @Test
public void testBatch2(){
List<Class> classList=session.createQuery("from Class").list(); } }
运行结果显示:
Hibernate: select class0_.classId as classId1_0_, class0_.className as classNam2_0_ from t_class class0_
Hibernate: select students0_.classId as classId3_0_1_, students0_.stuId as stuId1_1_1_, students0_.stuId as stuId1_1_0_, students0_.stuName as stuName2_1_0_, students0_.classId as classId3_1_0_ from t_student students0_ where students0_.classId in (?, ?, ?)
假如我们将Class.hbm.xml的batch-size="3"改成batch-size="2"的话,运行结果显示:
Hibernate: select class0_.classId as classId1_0_, class0_.className as classNam2_0_ from t_class class0_
Hibernate: select students0_.classId as classId3_0_1_, students0_.stuId as stuId1_1_1_, students0_.stuId as stuId1_1_0_, students0_.stuName as stuName2_1_0_, students0_.classId as classId3_1_0_ from t_student students0_ where students0_.classId in (?, ?)
Hibernate: select students0_.classId as classId3_0_1_, students0_.stuId as stuId1_1_1_, students0_.stuId as stuId1_1_0_, students0_.stuName as stuName2_1_0_, students0_.classId as classId3_1_0_ from t_student students0_ where students0_.classId=?
第三节:检索策略属性Fetch
1,Fetch:select(默认) 查询方式;
2,Fetch:subselect 子查询方式;
3,Fetch:join 迫切左外连接查询方式;
1,Fetch:select(默认) 查询方式;
Class.hbm.xml
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> <hibernate-mapping package="com.wishwzp.model"> <class name="Class" table="t_class">
<id name="id" column="classId">
<generator class="native"></generator>
</id> <property name="name" column="className"></property> <set name="students" cascade="delete" inverse="true" lazy="false" batch-size="2" fetch="select">
<key column="classId"></key>
<one-to-many class="com.wishwzp.model.Student"/>
</set>
</class> </hibernate-mapping>
StudentTest.java
package com.wishwzp.service; import java.util.Iterator;
import java.util.List;
import java.util.Set; import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.junit.After;
import org.junit.Before;
import org.junit.Test; import com.wishwzp.model.Class;
import com.wishwzp.model.Student;
import com.wishwzp.util.HibernateUtil; public class StudentTest { private SessionFactory sessionFactory=HibernateUtil.getSessionFactory();
private Session session; @Before
public void setUp() throws Exception {
session=sessionFactory.openSession(); // 生成一个session
session.beginTransaction(); // 开启事务
} @After
public void tearDown() throws Exception {
session.getTransaction().commit(); // 提交事务
session.close(); // 关闭session
} @Test
public void testFetch1(){
List<Class> classList=session.createQuery("from Class").list();
Iterator it=classList.iterator();
Class c1=(Class)it.next();
Class c2=(Class)it.next();
Class c3=(Class)it.next();
c1.getStudents().iterator();
c2.getStudents().iterator();
c3.getStudents().iterator();
} }
运行结果显示:
Hibernate: select class0_.classId as classId1_0_, class0_.className as classNam2_0_ from t_class class0_
Hibernate: select students0_.classId as classId3_0_1_, students0_.stuId as stuId1_1_1_, students0_.stuId as stuId1_1_0_, students0_.stuName as stuName2_1_0_, students0_.classId as classId3_1_0_ from t_student students0_ where students0_.classId in (?, ?)
Hibernate: select students0_.classId as classId3_0_1_, students0_.stuId as stuId1_1_1_, students0_.stuId as stuId1_1_0_, students0_.stuName as stuName2_1_0_, students0_.classId as classId3_1_0_ from t_student students0_ where students0_.classId=?
2,Fetch:subselect 子查询方式;
Class.hbm.xml
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> <hibernate-mapping package="com.wishwzp.model"> <class name="Class" table="t_class">
<id name="id" column="classId">
<generator class="native"></generator>
</id> <property name="name" column="className"></property> <set name="students" cascade="delete" inverse="true" lazy="false" batch-size="2" fetch="subselect">
<key column="classId"></key>
<one-to-many class="com.wishwzp.model.Student"/>
</set>
</class> </hibernate-mapping>
StudentTest.java
package com.wishwzp.service; import java.util.Iterator;
import java.util.List;
import java.util.Set; import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.junit.After;
import org.junit.Before;
import org.junit.Test; import com.wishwzp.model.Class;
import com.wishwzp.model.Student;
import com.wishwzp.util.HibernateUtil; public class StudentTest { private SessionFactory sessionFactory=HibernateUtil.getSessionFactory();
private Session session; @Before
public void setUp() throws Exception {
session=sessionFactory.openSession(); // 生成一个session
session.beginTransaction(); // 开启事务
} @After
public void tearDown() throws Exception {
session.getTransaction().commit(); // 提交事务
session.close(); // 关闭session
} @Test
public void testFetch1(){
List<Class> classList=session.createQuery("from Class").list();
Iterator it=classList.iterator();
Class c1=(Class)it.next();
Class c2=(Class)it.next();
Class c3=(Class)it.next();
c1.getStudents().iterator();
c2.getStudents().iterator();
c3.getStudents().iterator();
} }
运行结果显示:
Hibernate: select class0_.classId as classId1_0_, class0_.className as classNam2_0_ from t_class class0_
Hibernate: select students0_.classId as classId3_0_1_, students0_.stuId as stuId1_1_1_, students0_.stuId as stuId1_1_0_, students0_.stuName as stuName2_1_0_, students0_.classId as classId3_1_0_ from t_student students0_ where students0_.classId in (select class0_.classId from t_class class0_)
3,Fetch:join 迫切左外连接查询方式;
Class.hbm.xml
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> <hibernate-mapping package="com.wishwzp.model"> <class name="Class" table="t_class">
<id name="id" column="classId">
<generator class="native"></generator>
</id> <property name="name" column="className"></property> <set name="students" cascade="delete" inverse="true" lazy="false" batch-size="2" fetch="join">
<key column="classId"></key>
<one-to-many class="com.wishwzp.model.Student"/>
</set>
</class> </hibernate-mapping>
StudentTest.java
package com.wishwzp.service; import java.util.Iterator;
import java.util.List;
import java.util.Set; import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.junit.After;
import org.junit.Before;
import org.junit.Test; import com.wishwzp.model.Class;
import com.wishwzp.model.Student;
import com.wishwzp.util.HibernateUtil; public class StudentTest { private SessionFactory sessionFactory=HibernateUtil.getSessionFactory();
private Session session; @Before
public void setUp() throws Exception {
session=sessionFactory.openSession(); // 生成一个session
session.beginTransaction(); // 开启事务
} @After
public void tearDown() throws Exception {
session.getTransaction().commit(); // 提交事务
session.close(); // 关闭session
} @Test
public void testFetch2(){
Class c=(Class)session.get(Class.class, Long.valueOf(1));
}
}
运行结果显示:
Hibernate: select class0_.classId as classId1_0_0_, class0_.className as classNam2_0_0_, students1_.classId as classId3_0_1_, students1_.stuId as stuId1_1_1_, students1_.stuId as stuId1_1_2_, students1_.stuName as stuName2_1_2_, students1_.classId as classId3_1_2_ from t_class class0_ left outer join t_student students1_ on class0_.classId=students1_.classId where class0_.classId=?
END
(九)Hibernate 检索策略的更多相关文章
- Hibernate —— 检索策略
一.Hibernate 的检索策略本质上是为了优化 Hibernate 性能. 二.Hibernate 检索策略包括类级别的检索策略.和关联级别的检索策略(<set> 元素) 三.类级别的 ...
- hibernate(八) Hibernate检索策略(类级别,关联级别,批量检索)详解
序言 很多看起来很难的东西其实并不难,关键是看自己是否花费了时间和精力去看,如果一个东西你能看得懂,同样的,别人也能看得懂,体现不出和别人的差距,所以当你觉得自己看了很多书或者学了很多东西的时候,你要 ...
- Hibernate 检索策略
概述 检索数据时的 2 个问题: –不浪费内存:当 Hibernate 从数据库中加载 Customer 对象时, 如果同时加载所有关联的 Order 对象, 而程序实际上仅仅需要访问 Custome ...
- Hibernate检索策略(抓取策略)(Hibernate检索优化)
一.查询方法中get方法采用策略是立即检索,而load方法采用策略是延迟检索,延迟检索是在使用数据时才发送SQL语句加载数据 获取延迟加载数据方式:1.使用的时候,如果Customer c=sessi ...
- [原创]java WEB学习笔记88:Hibernate学习之路-- -Hibernate检索策略(立即检索,延迟检索,迫切左外连接检索)
本博客的目的:①总结自己的学习过程,相当于学习笔记 ②将自己的经验分享给大家,相互学习,互相交流,不可商用 内容难免出现问题,欢迎指正,交流,探讨,可以留言,也可以通过以下方式联系. 本人互联网技术爱 ...
- Hibernate检索策略
1. Hibernate的检索策略概述: 检索数据时的 2 个问题: 1.不浪费内存:当 Hibernate 从数据库中加载 Customer 对象时, 如果同时加载所有关联的 Order 对象 ...
- Hibernate学习(八)———— Hibernate检索策略(类级别,关联级别,批量检索)详解
序言 很多看起来很难的东西其实并不难,关键是看自己是否花费了时间和精力去看,如果一个东西你能看得懂,同样的,别人也能看得懂,体现不出和别人的差距,所以当你觉得自己看了很多书或者学了很多东西的时候,你要 ...
- hibernate检索策略(抓取策略)
检索策略 类级别检索 默认检索策略:默认延迟加载, 可以使用lazy属性来进行改变. session.get(clazz,object)默认立即加载 @Test //测试左外连接查询 public v ...
- Hibernate检索策略与检索方式
hibernate的Session在加载Java对象时,一般都会把鱼这个对象相关联的其他Java对象也都加载到缓存中,以方便程序的调用.但很多情况下,我们不需要加载太多无用的对象到缓存中,一来会占用大 ...
随机推荐
- iOS 详解NSXMLParser方法解析XML数据方法
前一篇文章已经介绍了如何通过URL从网络上获取xml数据.下面介绍如何将获取到的数据进行解析. 下面先看看xml的数据格式吧! <?xml version="1.0" enc ...
- UVa123 - Searching Quickly
题目地址:点击打开链接 C++代码: #include <iostream> #include <set> #include <map> #include < ...
- support-v4不能查看源码
在Android实际开发过程中往往会遇到使用v4,v7或v13兼容包中的一些类如ViewPager,Fargment等,但却无法关联源码 具体步骤: 1 右击Android项目中libs文件夹下的an ...
- VirtualBox NAT方式与主机互相通信
之前说过,桥接方式适合在统一的网络环境中使用(一样的网关和许可). 如果网络环境发生改变,那就难堪了 -- 这就是我遇到的问题,公司里每人的IP都是固定的. 解决办法,改为NAT网络地址转换模式. 但 ...
- 消息队列数量统计(MSMQ,Performance Counter)
微软消息队列服务MSMQ (Microsoft Message Queue),工作在在线或者离线场景,并提供异步编程功能.互联网和企业开发很多场景应用,例如电商的订单处理流程,这是因为客户端不需要等待 ...
- 在Win8 Mertro 中使用SQLite
在Win8 Mertro 中使用SQLite 分类: .net 开发 2012-09-19 18:17 1229人阅读 评论(3) ...
- 剑指OFFER之包含min函数的栈(九度OJ1522)
题目描述: 定义栈的数据结构,请在该类型中实现一个能够得到栈最小元素的min函数. 输入: 输入可能包含多个测试样例,输入以EOF结束. 对于每个测试案例,输入的第一行为一个整数n(1<=n&l ...
- eclipse项目导入到Android Studio Plugin with id 'android-library' not found
在主项目的build.gradle 中加入以下代码buildscript { repositories { mavenCentral() } dependencies { classpath 'com ...
- linux下eclipse的安装
Eclipse的安装http://java.sun.com/javace/downloads/index.jsp下载:Jdk-6u17-linux-i586.binhttp://www.eclipse ...
- Eclipse+Maven构建web项目及部署时Maven lib依赖问题的解决
目录 Eclipse中m2e插件构建web项目的步骤 Maven工具构建web项目再导入Eclipse的步骤 [一].Eclipse中m2e插件构建web项目的步骤 第一步:创建项目,按照 New – ...