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

Spring usage is not excluding Object field #40

Open
dhoffer opened this issue Dec 30, 2016 · 0 comments
Open

Spring usage is not excluding Object field #40

dhoffer opened this issue Dec 30, 2016 · 0 comments

Comments

@dhoffer
Copy link

dhoffer commented Dec 30, 2016

I'm using this in a Spring (Boot) application so have followed the instructions to create the JsonViewSupportFactoryBean Bean however its not excluding the excluded entity field at all. The excluded field is a reference to another domain entity.

Here is the entity:

`public class Attitudestate
implements java.io.Serializable,
UniquelyIdentified
{
private Long id;
private Runcatalog runidentity;
private Integer runidentityId;
private Double gpstime;
private Date utctimestamp;
private transient Double[] attitude;
private Float attitudeerror;
private Float currentangularrate;
private Float angularrateerror;

@JoinColumn(name = "runidentity", nullable = false)
@ManyToOne(fetch = FetchType.LAZY)
@XmlTransient
public Runcatalog getRunidentity()
{
    return this.runidentity;
}

public void setRunidentity(Runcatalog runidentity)
{
    this.runidentity = runidentity;
}`

In my controller I have:

`private JsonResult json = JsonResult.instance();

public Page findByRunIdentityId(Integer runidentityId, Pageable pageable)
{
Page attitudestates = repository.findByRunIdentityId(runidentityId, pageable);

    return json.use(JsonView.with(attitudestates)
        .onClass(Attitudestate.class, Match.match()
            .exclude("runidentity")))
        .returnValue();
}`

However the resulting REST response has the runidentity instance which by the way contains a reference to Attitudestate. I want to simply ignore runidentity in the REST response as it already has runidentityId. I can do this with which I can do with @JsonIgnore in the entity but I would prefer to not change my entities.

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

No branches or pull requests

1 participant