如何在Java中的对象中映射set()?
我在具有1组的对象中有1个对象。当数据从API传输并从数据库中获取数据时,我们如何映射2集<>一起?目前,我在错误的时间在正确的时间绘制结果。因为每次请求数据时,设置的排序都不同,这会导致设置请求的顺序并设置为偏斜,并且地图不能。
请求的示例JSON:
{
"id": "4028828d",
"facilityResults": [
{
"id": "4024decaa62003b",
"value": "1",
"note": "hau nha 656251"
},
{
"id": "4028828d7f003c",
"value": "12"
"note": "hy 52s"
}
]}
executeCheckList
public class ExecuteChecklist extends SiteBaseHest {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private String id;
@Column(name = "code", length = 20)
private String code;
@Column(name = "area_aft", length = 100)
private String areaAft;
@OneToMany(mappedBy = "executeChecklist")
@EqualsAndHashCode.Exclude
@JsonManagedReference
private Set<ChecklistStepRst> checklistStepRst; }
executechecteCheckListupDatesdto
public class ExecuteChecklistUpdatesDTO{
@NotBlank(message = "id can not be null or empty")
@Size(max = 32, message = "id length must be less than or equal 32 characters")
private String id;
@Size(max = 20, message = "code length must be less than or equal 20 characters")
private String code;
@Size(max = 100, message = "area length must be less than or equal 100 characters")
private String areaAft;
private Set<ChecklistStepRstUpdatesDTO> checklistStepRstUpdatesDTO; }
i To Map()set&lt;清单steprstupdatesdto&gt; ChatlistStePrstupDatesdto;
和set&lt;清单Steprst&gt;清单steprst;
,但是当JSON更改传递的值时,其排序将更改。放弃错误:
...实例的标识符从x更改为y(x to:id,y to:id be:id)
I have 1 Object in Object which has 1 set. When the data is transmitted from the API and the data is taken from the database, how can we map 2 sets<> together? Currently, I map the results at the right time at the wrong time. Because each time data is requested, set is ordered differently, which causes the order of set request and set to be skewed and the map cannot be.
Example JSON of request:
{
"id": "4028828d",
"facilityResults": [
{
"id": "4024decaa62003b",
"value": "1",
"note": "hau nha 656251"
},
{
"id": "4028828d7f003c",
"value": "12"
"note": "hy 52s"
}
]}
ExecuteChecklist
public class ExecuteChecklist extends SiteBaseHest {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private String id;
@Column(name = "code", length = 20)
private String code;
@Column(name = "area_aft", length = 100)
private String areaAft;
@OneToMany(mappedBy = "executeChecklist")
@EqualsAndHashCode.Exclude
@JsonManagedReference
private Set<ChecklistStepRst> checklistStepRst; }
ExecuteChecklistUpdatesDTO
public class ExecuteChecklistUpdatesDTO{
@NotBlank(message = "id can not be null or empty")
@Size(max = 32, message = "id length must be less than or equal 32 characters")
private String id;
@Size(max = 20, message = "code length must be less than or equal 20 characters")
private String code;
@Size(max = 100, message = "area length must be less than or equal 100 characters")
private String areaAft;
private Set<ChecklistStepRstUpdatesDTO> checklistStepRstUpdatesDTO; }
I want to map() Set< ChecklistStepRstUpdatesDTO > checklistStepRstUpdatesDTO;
and Set< ChecklistStepRst > checklistStepRst;
But when JSON changes the value passed, its sort is changed. give up error :
identifier of an instance of ... was altered from X to Y ( X to be: id, Y to be: id )
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
@bohemian
i map()with:
从数据库上传和检索时的设施results()的顺序是不同的,我不能一起映射()它们
@Bohemian
I map() with:
The order of facilityResults() when uploading and retrieving from the database is different and I can't map() them together