Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
messaoudi-mounir opened this issue Jul 5, 2018 · 2 comments
Labels
need-test-case Needs a test case (unit test or such) to proceed

Comments

@messaoudi-mounir
Copy link

messaoudi-mounir commented Jul 5, 2018

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);
}
@ssijak
Copy link

ssijak commented Dec 13, 2018

@cowtowncoder
Copy link
Member

Problems related to Spring handling of things need to be handled via Spring support: issues here need to be reproducible without using Spring components. This because often integration by frameworks is the main reason for failures -- so to eliminate that possibility, Jackson-only unit tests are the way to go.

@cowtowncoder cowtowncoder added need-test-case Needs a test case (unit test or such) to proceed and removed need-unit-test labels Jan 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need-test-case Needs a test case (unit test or such) to proceed
Projects
None yet
Development

No branches or pull requests

4 participants
@cowtowncoder @messaoudi-mounir @ssijak and others