05_retrieve_strategy.pptVIP

  • 1
  • 0
  • 约 13页
  • 2016-11-28 发布于河南
  • 举报
05_retrieve_strategy

Hibernate的检索策略 教学内容 立即检索策略 延迟检索策略 迫切左外连接检索策略 每种检索策略的适用范围 在程序中显式指定迫切左外连接检索策略 CUSTOMERS表和ORDERS表中的记录 运行Session的find()方法 List customerLists=session.find(from Customer as c); 运行以上find()方法时,Hibernate将先查询CUSTOMERS表中所有的记录,然后根据每条记录的ID,到ORDERS表中查询有参照关系的记录,Hibernate将依次执行以下select语句: select * from CUSTOMERS; select * from ORDERS where CUSTOMER_ID=1; select * from ORDERS where CUSTOMER_ID=2; select * from ORDERS where CUSTOMER_ID=3; select * from ORDERS where CUSTOMER_ID=4; Customer与Order对象的关联对象图 默认的立即检索策略的缺点 select语句的数目太多,需要频繁的访问数据库,会影响检索性能。如果需要查询n个Customer对象,那么必须执行n+1次select查询语句。这种检索策略没有利用SQL的连接查

文档评论(0)

1亿VIP精品文档

相关文档