How to get around Jackson's inability to handle direct self-references in JPA beans

后端 未结 1 1841
我在风中等你
我在风中等你 2021-01-18 19:23

So I am working on a RESTful data API using Java, Hibernate, JPA annotations, JAX-RS annotations, JAXB annotations, Jersey, and the Jackson JSON parser.

After trying

相关标签:
1条回答
  • 2021-01-18 19:53

    Jackson 1.x does not have specific support for resolving cyclic references, but there is support for handling parent/child style dependencies: this blog entry has more info.

    Jackson 2.0 will have support for arbitrary Object Id / reference handling, using new @JsonIdentityInfo annotation, so perhaps that could be used to solve the problem. Official 2.0 release is not out yet, but release candidates (latest being RC2) are, in case you wanted to have a look. Not sure if it would handle your problem, but maybe it would help.

    EDIT: Actually, Jackson JAXB annotation module will have support for @XmlID / @XmlIDREF for 2.0.0 -- this was just implemented, see here.

    0 讨论(0)
提交回复
热议问题