-Session何时清理缓存-Hibernate缓存深入详解

时间:2021-04-22 19:41:01
【文件属性】:
文件名称:-Session何时清理缓存-Hibernate缓存深入详解
文件大小:3.54MB
文件格式:PPT
更新时间:2021-04-22 19:41:01
hibernate 2-5:Session何时清理缓存(1) session缓存中对象的属性每次发生变化,Session不会立即清理缓存及执行相关的update语句,而是在特定的时间点才清理缓存,这使得Session能够把几条相关的sql语句合并为一条sql语句,以便减少访问数据库的次数。 以下代码对dept对象的deptName属性修改了两次: Transaction tx = session.biginTransaction(); Dept dept = (Dept)session.get(Dept.class,”001”); dept.setDeptName(“人事部”); dept.setDeptName(“人力资源部”); tx.commit(); 当Session清理缓存时,只会执行一条update语句 *

网友评论