| As posted on stackoverflow https://stackoverflow.com/questions/47200195/hibernate-envers-load-lazy-entities-for-a-revision, trying to use Hibernate.initialize on a proxy object to initialize it, seems not working. I attach the small project. Because I was not surehow to create a test case really equals to my case, in order to see the problem you have to run the spring boot application, then: 1===== Make this request:
GET /licensePlates/1/revisions HTTP/1.1
Host: localhost:8080
Cache-Control: no-cache
Postman-Token: 8ace37aa-9706-d9a5-21fb-8d195b44418c
Keep in mind the number of the revision. Anyone is good. 2====== Execute this request:
GET /licensePlates/1/revisions/3 HTTP/1.1
Host: localhost:8080
Cache-Control: no-cache
Postman-Token: 23a77d08-4d18-e185-dc74-23e6384b409a
You will have this exception:
{
"timestamp": 1510610843985,
"status": 500,
"error": "Internal Server Error",
"exception": "org.springframework.http.converter.HttpMessageNotWritableException",
"message": "Could not write JSON: 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); nested exception is com.fasterxml.jackson.databind.JsonMappingException: 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: org.springframework.hateoas.Resource[\"content\"]->it.text.demo.domain.Country_$$_jvstba_2[\"handler\"])",
"path": "/licensePlates/1/revisions/3"
This even if the return value was initializated with Hibernate.initialize(current.getCountry()); |