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.
/cc @FroMage, @loicmathieu
I'll take a stab at this since I'm pretty sure I know what's going on
perfect, thanks! Any chance to get this fix included in the upcoming 1.6.0?
I think it should be backported, WDYT @FroMage ?
Same problem here.
I have the same problem with quarkus 1.7.1-Final.
I annotated field, getter and setter, with no effect.
Mine is a little bit different. My application throws error when trying to serialize PanacheEntity properties extended by all model classes I have.
Still broken in quarkus 1.9.2.FINAL and 1.8.1.FINAL
Can you open a new issue with a reproducer please?
@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.
That's an easy to mistake to make TBH :)
For my project, the issue was caused by using both jackson and jsonb. After removing jsonb from the dependencies, @JsonIgnore was honored again.