代码运行没有问题 但是延迟加载没有效果
图片中是debug效果 输出c 这个语句还没有执行就已经打印了sql语句这个结果和get方法结果一模一样
延迟加载应该是使用时才打印sql语句然后和结果一起输出 求大神指点
com.mysql.jdbc.Driver
jdbc:mysql:///hibernate32
root
root
org.hibernate.dialect.MySQLDialect
true
true
update
4
thread
<mapping resource="cn/itcast/domain/Customer.hbm.xml" />
</session-factory>
@Test
public void fun2(){
Session session = HibernateUtils.openSession();
Transaction tx = session.beginTransaction();
//----------------------------------------------------
Customer c = session.load(Customer.class, 2l);
System.out.println(c);
//----------------------------------------------------
tx.commit();
session.close();
}