Skip to content

Spring Controller annotated with @JsonView and hibernate5 return null #118

Open
@messaoudi-mounir

Description

@messaoudi-mounir

I think it's similar issue #73

With Spring along @JSONVIEW all Lazy fields will be initiated and serialized,
but when integrate hibernate5 module, the returned value is null (example relEntity return value is null) .

@Entity
@Table(name = "my_table")
public class MyEntity {
  ...
 @ManyToOne(fetch = FetchType.LAZY, optional = false) 
 @JsonView(Views.Public.class)
 private RelatedEntity relEntity;
...
}

Call from some Spring Rest controller:

@JsonView(Views.Public.class)
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
public MyEntity getObject(@PathVariable(name = "id") UUID id) {
    return service.findByUuid(id);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    need-test-caseNeeds a test case (unit test or such) to proceed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions