Jackson - Serialize entity with self-reference

前端 未结 2 564
忘掉有多难
忘掉有多难 2021-01-25 20:35

I have the following entity:

@Entity
@Table(name = \"registry_entry\")
@JsonIgnoreProperties(ignoreUnknown = true)
public class RegistryEntry extends GenericEnti         


        
2条回答
  •  温柔的废话
    2021-01-25 21:17

    Adding this annotatin to my class resolved my issue.

    @JsonIdentityInfo(generator = ObjectIdGenerators.IntSequenceGenerator.class, property = "id") 
    

    I had a self referencing entity for which Jackson was going in infinite loop. While the property in issue was transient still Jakson was trying to serialize and giving issue.

提交回复
热议问题