JsonMappingException: failed to lazily initialize及could not initialize异常

1、org.hibernate.LazyInitializationException: could not initialize proxy - no Session
hibernate的load(myVO)改为get(myVO)

2、JsonMappingException: could not initialize proxy - no Session
JsonMappingException: failed to lazily initialize a collection of role:
myVO增加 @JsonIgnoreProperties忽略导致报错的延迟加载对象

3、如果myVO中的延迟加载对象必须有值,可以用Hibernate.initialize把延迟加载的对象提前获取

Hibernate.initialize( myVO.getLazyObj() );

最不建议使用的方法:hibernate设置lazy=“false”

你可能感兴趣的:(Hibernate,REST)