I'm trying to serialize an entity with have a bidirectional relationship:
class TypeA {
String name;
TypeB typeB;
}
class TypeB {
String identifier;
TypeA typeA;
}
With Jackson I solve with @JsonBackReference in typeB attribute and @JsonManagedReference in typeA attribute, but how i can do this on JSONB (Eclipse Yasson implementation)?
Caused by: javax.json.bind.JsonbException: Recursive reference has been found in class class xxxxxx.model.Analysis.
at org.eclipse.yasson.internal.serializer.ObjectSerializer.serializeInternal(ObjectSerializer.java:76)
at org.eclipse.yasson.internal.serializer.AbstractContainerSerializer.serialize(AbstractContainerSerializer.java:107)
at org.eclipse.yasson.internal.serializer.AbstractContainerSerializer.serializerCaptor(AbstractContainerSerializer.java:125)
at org.eclipse.yasson.internal.serializer.ObjectSerializer.marshallProperty(ObjectSerializer.java:121)
at org.eclipse.yasson.internal.serializer.ObjectSerializer.serializeInternal(ObjectSerializer.java:69)
... 45 more
OBS: I solved with a DTO but the doubt stayed.
For solving the circular structure you should use @JsonbTransient. As stated in documentation [0]:
[0]: http://json-b.net/docs/user-guide.html#ignoring-properties
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With