@JsonBackReference with intermediate object

10 views
Skip to first unread message

Clément Poulain

unread,
Nov 15, 2019, 9:03:36 AM11/15/19
to jackson-user
Hi,

I'm trying to use @JsonManagedReference and @JsonBackReference with an intermediate object in bewteen.

Let's say I have those 3 objects:

    class Parent {

        Bucket childrenBucket;

    }

    class Bucket {

        @JsonManagedReference
        List<Child> children;

    }

    class Child {

        @JsonBackReference
        Parent parent;

    }

This is failing because of: "com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot handle managed/back reference 'defaultReference': back reference type (Parent) not compatible with managed type (Bucket)"

Is there a way to achieve this?

Thanks!

Tatu Saloranta

unread,
Nov 15, 2019, 1:37:58 PM11/15/19
to jackson-user
No, managed/back reference pair must be compatible. No other set ups
are supported.

-+ Tatu +-
Reply all
Reply to author
Forward
0 new messages