Skip to content

@JsonIgnoreProperties("filed") annotations are not respected by NestedEntitySerializer [DATAREST-1236] #1596

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

Open
spring-projects-issues opened this issue Apr 26, 2018 · 6 comments
Assignees
Labels
type: bug A general bug

Comments

@spring-projects-issues
Copy link

Phil Webb opened DATAREST-1236 and commented

Originally raised as a spring boot issue along with a project that shows the issue it appears that the @JsonIgnoreProperties("field") annotation is currently being ignored by Spring Data Rest.

After a bit of digging I think it is due to the custom NestedEntitySerializer. Specifically this line which serializes the value without providing Jackson access to the field annotations


1 votes, 6 watchers

@spring-projects-issues
Copy link
Author

Robson Farias commented

Hi, just a small correction, the Jackson annotation is @JsonIgnoreProperties("field"). @JsonIgnore works ok. Thanks for raising this issue!

@spring-projects-issues
Copy link
Author

Phil Webb commented

Robson Farias Thanks, I've edited the description

@spring-projects-issues
Copy link
Author

Oliver Drotbohm commented

Hm, I'm not sure the serializer is the place to fix this. TBCH, I wouldn't even have expected the serializer to be triggered for a property that's marked as ignored as I assumed Jackson to calculate the list of properties to serialize first and only trigger serializers for the ones that survive the filtering. I'd have to check whether our custom BeanSerializerModifier messes this up

@spring-projects-issues
Copy link
Author

Brian Strom commented

This one has been out for a while and seems to be understood pretty well. Any chance of getting some attention to it? JsonIgnoreProperties is a particularly helpful annotation. (to me at least!)

@spring-projects-issues
Copy link
Author

deftdawg commented

I've spent a couple of days trying to figure out why fields marked as JsonIgnoreProperties like this:

@ManyToOne
@JsonIgnoreProperties(value = "myclass", allowSetters = true)
private Company customer;    

are effectively attempting to serialize my entire database and return it in the JSON value in my ResponseEntity. 
 
JsonIgnoreProperties supposed to prevent that recursion through object relationships when serializing to JSON. 
 
It's good to know that maybe the problem is not what I'm doing, but rather the underlying implementation is broken.
 
Does anyone have a good approach/example for returning objects with complicated relationships where those are properly swapped out for HATEOAS links so ResponseEntity's can be used?   I can't find anything that's anywhere near current that works (most code I've found refers to Resource and stuff like that that has been replaced since spring-hateoas 1.0).
 

@HashirLabs
Copy link

any progress on this, this is very random that it works in one project for me while it does not in the other, the target property i am try to ignore is of type Set.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

3 participants