Skip to content

@JsonIgnoreProperties doesn't work in certain conditions #12968

Closed
@GuiRitter

Description

@GuiRitter

Hi everyone.

As per this discussion and others I read elsewhere, it should be possible to use @JsonIgnoreProperties to hide properties of entity properties. However, I performed several tests and sometimes it works, sometimes it doesn't.

In the simplest case, an User entity that has an @OneToOne relationship with an UserPermission entity cannot hide UserPermission's hidden property via @JsonIgnoreProperties("hidden"), when accessing a @RepositoryRestResource via REST.

If the repository is used with excerptProjection = UserProjection.class, and the projection uses UserPermission instead of UserPermissionProjection, it works. If both are projections, it doesn't work.

By @Autowireding an ObjectMapper, doing the serialization in a @RepositoryRestController and printing the result with System.out, any case works.

Here's a project that reproduces the issue. Clone/download, build with Maven, run DemoApplication.java and access http://localhost:8080/users from any browser. The hidden properties should not appear.

Thanks in advance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    for: external-projectFor an external project and not something we can fix

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions