是否有注释获取EmbeddedId值而不是对象?

时间:2019-03-26 11:54:34

标签: json spring-boot jpa

我正在尝试在一个级别而不是多个级别上打印实体的参数

我尝试了DTO解决方案。它可以工作,但是我正在寻找注释来帮助我。

实体类

@Entity
public class MyClass implements Serializable {
    private static final long serialVersionUID = 1L;

    @EmbeddedId
    private MyClassPK id;

    @Column(name="Ordr_No")
    private BigDecimal ordrNo;

    @Column(name="Desc")
    private String desc;
   ....
}

Id类

@Embeddable
public class MyClassPK implements Serializable {
    //default serial version id, required for serializable classes.
    private static final long serialVersionUID = 1L;

    @Column(name="Name")
    private String name;

    @Column(name="Location")
    private String location;
...
}

Json Response是

{
     "id": {
         "name": "value",
         "locatoin": "value"
     },
     "ordrNo": 3,
     "desc": "value"
 }

我想要它

{
    "name": "value",
    "locatoin": "value",
    "ordrNo": 3,
    "desc": "value"
 }

0 个答案:

没有答案