@Embeddable
@Access(AccessType.FIELD)
public class LobValue {
private String s;
public String getS() {
return s;
}
public void setS(String s) {
this.s = s;
}
}
However when I try to access http://localhost:8080/rest/productEntities from the browser I get the following exception:
Caused by: org.hibernate.LazyInitializationException: failed to lazily initialize a collection, could not initialize proxy - no Session
at org.hibernate.collection.internal.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:579)
at org.hibernate.collection.internal.AbstractPersistentCollection.withTemporarySessionIfNeeded(AbstractPersistentCollection.java:203)
at org.hibernate.collection.internal.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:558)
at org.hibernate.collection.internal.PersistentMap.put(PersistentMap.java:163)
at org.springframework.data.rest.webmvc.json.PersistentEntityJackson2Module$NestedEntitySerializer.serialize(PersistentEntityJackson2Module.java:362)
at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:693)
at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:690)
... 140 more
which happens when the PersistentEntityJackson2Module tries to serialize the json.
This code works perfectly fine with Gosling-SR4 but the exception happens with Hopper or Ingals.
Here's a sample repository that reproduces this behavioud:
Should be an easy fix as this seems to related to Spring's CollectionFactory using the native Hibernate type which in turn requires an active Session.
Generally speaking, we use priorities to indicate severance regarding the overall functionality of the library. Otherwise every ticket would be filed as blocker
Please give the snapshots a try. Also, sample projects are most helpful if they're as small as possible and contain a failing test case and then we can just run the build to verify the fix. Having to issue particular requests manually is suboptimal as introduces a lot of other vectors that could potentially cause issues
Petar Tahchiev opened DATAREST-897 and commented
Hello,
I have the following JPA entity which I want to expose via rest:
where the
LobValue
is an embeddable:However when I try to access
http://localhost:8080/rest/productEntities
from the browser I get the following exception:which happens when the
PersistentEntityJackson2Module
tries to serialize the json.This code works perfectly fine with
Gosling-SR4
but the exception happens withHopper
orIngals
.Here's a sample repository that reproduces this behavioud:
http://github.com/ptahchiev/demo-rest-problem
Just start the project with
mvn spring-boot:run
and then navigate tohttp://localhost:8080/rest/productEntities
.P.S. I mark this with blocker because it blocks me to update to Hopper or Ingalls
Referenced from: commits bacd8be, 759ba86
Backported to: 2.5.3 (Hopper SR3)
The text was updated successfully, but these errors were encountered: