`
zzhangyx
  • 浏览: 68995 次
  • 性别: Icon_minigender_1
  • 来自: 福建
社区版块
存档分类
最新评论

HIBERNATE 错误

    博客分类:
  • JAVA
阅读更多

 

 

Hibernate异常:query specified join fetching, but the owner of the fetched association was not present in the select list

 

转至    yokubee

 

org.hibernate.QueryException: query specified join fetching, but the owner of the fetched association was not present in the select list

 


 

报这个异常是因为查询时返回的对象不包含有该join fetch后面的对象,因此可以将fetch删除就可以啦。这里的fetch就是将fetch后面的对象setter到查询返回的对象中。因此当不存在包含时,就会该报错!

 

 

 

[java] view plaincopy
  1. //这里Student和Teacher为双向多对多关系  
  2. Query q = s.createQuery("select t from Student s left join fetch s.teachers t where t.id=1");  
  3. 这时就会报错啦!  

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics