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")
生成的语句没有查询多的一方 ,但是报错,错误为上述的错 ,我希望查询一的一方不查询多的一方。

你设置的是延迟加载,可以用Hibernate.initialize去强制加载。
比如类A,B是一对多的关系,可以调用Hibernate.initialize(a.getB())去强制加载