Hello. I am using Jackson with Resteasy to handle the conversion to/from
JSON in my rest resources. In a three-entity relationship, it seems to be
having difficulty with @JsonManagedReference and @JsonBackReference. I'm
getting the following error:
java.lang.IllegalArgumentException: Can not handle managed/back reference
Here is the code that is doing it:
@XmlRootElement
@Entity
@Table(name = "foo")
public class Foo extends Identity {
@JsonManagedReference("barReference")
@OneToOne(optional = false, fetch = FetchType.EAGER, cascade=CascadeType
.ALL)
@JoinColumn(name = "bar_id")
private Bar bar;
}
@XmlRootElement
@Entity
@Table(name = "bar")
public class Bar extends Identity {
@JsonBackReference("fooBackReference")
@OneToOne(mappedBy = "bar", targetEntity = Foo.class)
private Foo foo;
@JsonManagedReference("bazReference")
@OneToMany(mappedBy = "bar", cascade = CascadeType.ALL, targetEntity =
Baz.class, fetch = FetchType.EAGER)
private Set<Baz> baz;
}
@XmlRootElement
@Entity
@Table(name = "baz")
public class Baz extends Identity {
@JsonBackReference("barBackReference")
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "bar_id")
private Bar bar;
}
I have done quite a lot of searching via Google, but I can't see what I'm doing
wrong. Thanks in advance for any help.
Steve
--
You received this message because you are subscribed to the Google Groups
"jackson-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
For more options, visit https://groups.google.com/d/optout.