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

@JsonIgnore on fields in panache entity not working #10339

Closed
sbeigel opened this issue Jun 29, 2020 · 12 comments · Fixed by #10345
Closed

@JsonIgnore on fields in panache entity not working #10339

sbeigel opened this issue Jun 29, 2020 · 12 comments · Fixed by #10345
Assignees
Labels
area/panache kind/bug Something isn't working
Milestone

Comments

@sbeigel
Copy link

sbeigel commented Jun 29, 2020

Describe the bug
Starting with quarkus version 1.3.1 (until 1.6.0.CR1), ignoring fields with Jackson's @JsonIgnore annotation on the fields of panache entities doesn't work anymore. You have to add an explicit getter and place the annotation there to have an effect. That kind of defeats the purpose of panache's "property" style.

Expected behavior
Panache entity fields annotated with @JsonIgnore should be ignored in JSON serialization/deserialization.

@Entity
public class Fruit extends PanacheEntity {
    public String name;

    // the following "property" should be ignored in serialization/deserialization
    @JsonIgnore
    public String ignoredProperty;
}

should produce:

{
    id: 1,
    name: "Apple",
}

Actual behavior
Panache entity fields annotated with @JsonIgnore are NOT ignored in JSON serialization/deserialization.

{
    id: 1,
    name: "Apple",
    ignoredProperty: "ignored apple"
}

To Reproduce
I've created a reproducer including a test to show this behavior. Running mvn test using any quarkus version >= 1.3.1 will fail.

Reproducer

@sbeigel sbeigel added the kind/bug Something isn't working label Jun 29, 2020
@quarkusbot
Copy link

/cc @FroMage, @loicmathieu

@geoand
Copy link
Contributor

geoand commented Jun 29, 2020

I'll take a stab at this since I'm pretty sure I know what's going on

@geoand geoand self-assigned this Jun 29, 2020
geoand added a commit to geoand/quarkus that referenced this issue Jun 29, 2020
FroMage added a commit that referenced this issue Jun 30, 2020
@FroMage FroMage added this to the 1.7.0 - master milestone Jun 30, 2020
@sbeigel
Copy link
Author

sbeigel commented Jun 30, 2020

perfect, thanks! Any chance to get this fix included in the upcoming 1.6.0?

@geoand
Copy link
Contributor

geoand commented Jun 30, 2020

I think it should be backported, WDYT @FroMage ?

gsmet pushed a commit to gsmet/quarkus that referenced this issue Jun 30, 2020
@daibertdiego
Copy link

Same problem here.

@maegges65
Copy link

I have the same problem with quarkus 1.7.1-Final.
I annotated field, getter and setter, with no effect.

@icaroerasmo
Copy link

icaroerasmo commented Sep 14, 2020

Mine is a little bit different. My application throws error when trying to serialize PanacheEntity properties extended by all model classes I have.

@zteater
Copy link

zteater commented Nov 8, 2020

Still broken in quarkus 1.9.2.FINAL and 1.8.1.FINAL

@geoand
Copy link
Contributor

geoand commented Nov 8, 2020

Can you open a new issue with a reproducer please?

@zteater
Copy link

zteater commented Nov 9, 2020

@geoand I was able to isolate it to user error. I had both Jackson and Json-B in the cp, how embarrassing. Seems to be working with just Jackson on the cp.

@geoand
Copy link
Contributor

geoand commented Nov 9, 2020

That's an easy to mistake to make TBH :)

@maegges65
Copy link

For my project, the issue was caused by using both jackson and jsonb. After removing jsonb from the dependencies, @JsonIgnore was honored again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/panache kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants