如何修复Spring Boot中的“​​ TransientPropertyValueException”错误

时间:2019-04-09 06:38:52

标签: json rest spring-boot

我正在尝试使用json结构保存(POST),并且我需要使用外键(idClient和idUser),但这会产生所描述的错误,我不知道我是否正确发送了idClient手动创建,而不是自动生成。

并尝试通过注释解决它,但我做不到。

@JsonIgnore
    @OneToMany(mappedBy = "idClient", cascade = { CascadeType.PERSIST, CascadeType.MERGE,
            CascadeType.REMOVE}, fetch = FetchType.LAZY, orphanRemoval = true)
    private Collection<Pres> presCollection1;


@JsonIgnore
    @OneToMany(mappedBy = "idUser", cascade = { CascadeType.PERSIST, CascadeType.MERGE,
            CascadeType.REMOVE}, fetch = FetchType.LAZY, orphanRemoval = true)
    private Collection<Pres> presCollection2;



 @ManyToOne

    @JsonIgnoreProperties("id_client")
    @JoinColumn(name = "id_client",  referencedColumnName = "identi")
    private Person idClient;


    @ManyToOne

    @JsonIgnoreProperties("id_user")
    @JoinColumn(name = "id_user",  referencedColumnName = "identi")
    private Person idUser;



JSON TO SEND


{ 
    "date": "2019-03-24T05:00:00.000Z",
    "lastDate": "2019-09-24T05:00:00.000Z",
    "idClient":{"idClient":11},
    "idUser":{"idUser":12}

}

我需要保存客户端ID和用户ID

1 个答案:

答案 0 :(得分:0)

Select 
ST.Description
, CASE PATINDEX('% ([0-9]% x %) -%', ST.Description) 
        WHEN 0 THEN ST.Description
        ELSE SUBSTRING(ST.Description, PATINDEX('% ([0-9]% x %) -%', ST.Description) + 2, CHARINDEX('x', SUBSTRING(ST.Description, PATINDEX('% ([0-9]% x %) -%', ST.Description) + 2, 20))-2)
    END
 AS SubTaskQTY

From astTaskSubTasks ST

Join astTasks T ON T.Id = ST.ParentId
Join astAssets A ON A.Id = T.AssetId

Where A.Code = '2016100011'


SELECT  PATINDEX('% ([0-9]% x %) -%', '1 x -') 

您必须合并这些值,以便仅给级联类型合并。