java_wxp
java_wxp
2013-06-02 09:14

hibernate一对多注解 延迟加载失败

  • spring
  • hibernate

hibernate4.2

org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.xp.model.lmj.test_one.test_manys, could not initialize proxy - no Session
at org.hibernate.collection.internal.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:566)
at org.hibernate.collection.internal.AbstractPersistentCollection.withTemporarySessionIfNeeded(AbstractPersistentCollection.java:186)

@OneToMany(cascade = {CascadeType.MERGE,CascadeType.PERSIST,CascadeType.REFRESH},fetch = FetchType.LAZY,mappedBy = "testone")
生成的语句没有查询多的一方 ,但是报错,错误为上述的错 ,我希望查询一的一方不查询多的一方。

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

1条回答

为你推荐