1.load方式检索不到的话会抛出org.hibernate.ObjectNotFoundException异常
get方法检索不到的话会返回null。load 和get 都会去数据库检索。但 load 首先回去查session的persistent Context中是否有缓存。如果缓存中有的换回直接返回。
本文探讨了Hibernate框架中load与get方法的区别:load方法在检索不到数据时会抛出ObjectNotFoundException异常,并且会先检查Session的Persistent Context;而get方法检索不到数据时则返回null。
get方法检索不到的话会返回null。load 和get 都会去数据库检索。但 load 首先回去查session的persistent Context中是否有缓存。如果缓存中有的换回直接返回。

被折叠的 条评论
为什么被折叠?