I was having an issue with Gson because it can't pass to Json HibernateProxy objects, so I have followed this guide: link
This solve the typeAdapter problem with Gson, but now I'm getting the following exception:
org.hibernate.LazyInitializationException: could not initialize proxy - no Session
I have been searching how to solve this but the solutions that I have found don't work in this case.
This is my code:
List<ContratoSolicitudFull> returnValue =
new SomeBL().getData(id, null, null,currentUserId);
Type type = new TypeToken<List<ContratoSolicitudFull>>() {}.getType();
Gson gson = new GsonBuilder()
.registerTypeAdapter(DateTime.class, new DateTimeJsonConverter())
.registerTypeAdapter(LocalDate.class, new LocalDateJsonConverter())
.registerTypeAdapterFactory(HibernateProxyTypeAdapter.FACTORY)
.create();
String jsonValue = gson.toJson(returnValue, type); //Here is where it fail
Any idea?