-
Notifications
You must be signed in to change notification settings - Fork 563
Closed
Labels
type: enhancementA general enhancementA general enhancement
Milestone
Description
I have following class Note.java
@Entity
public class Note {
//.. id
@ManyToOne(fetch = FetchType.LAZY)
private Author author;
}When accessing a element via GET /notes/1 I receive follwing response.
{
"title" : "Note#1",
"text" : "Content#1",
"_links" : {
"self" : {
"href" : "http://localhost:8080/notes/1"
},
"note" : {
"href" : "http://localhost:8080/notes/1"
},
"author" : {
"href" : "http://localhost:8080/notes/1/author"
}
}
}But when doing GET http://localhost:8080/notes/1/author I get following exception:
com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for class org.hibernate.proxy.pojo.bytebuddy.ByteBuddyInterceptor and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) (through reference chain: org.springframework.data.rest.webmvc.json.PersistentEntityJackson2Module$PersistentEntityResourceSerializer$1["content"]->github.skreutz.model.Author$HibernateProxy$XZxIw8Hs["hibernateLazyInitializer"])
at com.fasterxml.jackson.databind.exc.InvalidDefinitionException.from(InvalidDefinitionException.java:77) ~[jackson-databind-2.14.1.jar:2.14.1]
When changing @ManyToOne(fetch = FetchType.LAZY) to @ManyToOne(fetch = FetchType.EAGER) this endpoints works fine.
I created a sample project: https://github.com/saschakr/spring-boot-data-rest-example
Metadata
Metadata
Assignees
Labels
type: enhancementA general enhancementA general enhancement