日期:2014-05-19  浏览次数:20784 次

Hibernate中 ManyToMany 报错
ManyToMany 中如果设置成 fetch=FetchType.LAZY就会报下面这个错
0 ERROR LazyInitializationException:42 - failed to lazily initialize a collection of role: com.ciat.permission.spring.model.ApUser.apPuviews, no session or session was closed
如果一个设置成 fetch=FetchType.EAGER 时Tomcat 启动时就会报
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in URL [file:/D:/FLEX/cljk/.metadata/.plugins/org.eclipse.wst.server.core/tmp2/wtpwebapps/CiatConstruct/WEB-INF/classes/applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.HibernateException: cannot simultaneously fetch multiple bags
 
初学者,这个应该怎么改。

------解决方案--------------------
围观一下 正在学spring呢 hibernate这个问题还真没遇到过 楼主是否在设置延时加载?
------解决方案--------------------
inversion="true" 你那个属性好像可以不用管