How to reference an entity with inheritance in Spring Data REST when POSTing new entity?

前端 未结 3 1592
我寻月下人不归
我寻月下人不归 2021-01-13 08:07

I have entities with joined inheritance:

Supporter

@Entity
@Inheritance(strategy=InheritanceType.JOINED)
@Js         


        
3条回答
  •  既然无缘
    2021-01-13 08:32

    You should be able to workaround this by setting @JsonTypeInfo(use= JsonTypeInfo.Id.NONE) at the property/method level e.g.

    Try with this:

    @ManyToOne // same error with @OneToOne
    @JoinColumn(name = "supporter_id", referencedColumnName = "id", nullable = false)
    @JsonTypeInfo(use= JsonTypeInfo.Id.NONE)
    public SupporterEntity getSupporter() {
        return supporter;
    }
    

提交回复
热议问题