任何人都可以对我有什么这两个代码之间的区别:什么是在休眠query.uniqueResult()VS session.load之间的差异
Session session = getSession() ; // this method check if there is an open session return it if it's not open a new session
Query query =session.createQuery("from Entity e where e.id=1");
Entity object = (Entity)query.uniqueResult();
和验证码:
Session session = getSession() ; // this method check if there is an open session return it if it's not open a new session
Entity object = (Entity)session.load(Entity.class, new Integer(1));
做的第一种方法返回一个代理对象?如果我再次调用它是否会触发数据库?
可能重复[在Hibernate中load()vs get()的优点是什么?](http://stackoverflow.com/questions/5370482/whats-the-advantage-of-load-vs-get在休眠) – Azodious
这不是确切的重复,但接受的答案也回答你的问题。 – Azodious
@有趣的是它不是关于query.uniqueResual()它是关于session.get()我认为他们有不同的行为 –