I have a class
public class ClassB
{
private ClassC c;
private List<ClasssA> a;
}
which I am returning in my controller method as response body. When I add @JsonIgnore to List object, I am getting response but when I include List, I am getting error as
Could not write content: No serializer found for class org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) ) (through reference chain: ......
This a common problem with
lazy Hibernate loading: Hibernate won't load the relationships for that particular object instance.
So that's why the error you get. Now the common solution and reported bug is Use this property
@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
Check more of this Bug Reported and more Lazy vs Eager
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.