You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
This is a very important annotation that should work, because it's also used to control Bidirectional relationship. With @JsonManagedReference and @JsonBackReference it could be controlled, but we lost the property with the @JsonBackReference, and sometimes we really need that property when working directly with the Entity. @JsonIgnoreProperties fills this gap, since we can controll in parent level. It would be really great if it worked.
@GuiRitter Sorry to bounce you about issue trackers but I think that this is a Spring Data REST issue. I've raised DATAREST-1236. Thanks for the sample project, it was very helpful in determining what was going on.
Thanks for raising the issue in Jira and sorry for posting in the wrong project. Earlier tests made me believe it was an issue with Boot and that it wouldn't happen without it, but I couldn't (in a reasonable amount of time) reproduce the same use case without Boot.
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 anUserPermission
entity cannot hideUserPermission
'shidden
property via@JsonIgnoreProperties("hidden")
, when accessing a@RepositoryRestResource
via REST.If the repository is used with
excerptProjection = UserProjection.class
, and the projection usesUserPermission
instead ofUserPermissionProjection
, it works. If both are projections, it doesn't work.By
@Autowired
ing anObjectMapper
, doing the serialization in a@RepositoryRestController
and printing the result withSystem.out
, any case works.Here's a project that reproduces the issue. Clone/download, build with Maven, run
DemoApplication.java
and accesshttp://localhost:8080/users
from any browser. Thehidden
properties should not appear.Thanks in advance.
The text was updated successfully, but these errors were encountered: