1.entity
public class SaledData implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(value = "id", type = IdType.AUTO)
private Long id;
private LocalDate recordDate; // has unique index
...
}
2.fetch data from remote then save to mysql db
@Scheduled(cron = "0 0 1/1 * * ?")
public void getSaledData() {
@Resource private ISaledDataService iSaledDataService;
SaledData saledData = new SaledData();
...
iSaledDataService.save(saledData);
// sometimes has repeated data will intercept by unique index
}
3.wrong id’s result
"id": 158,
"createTime": "2024-05-13T04:00:08",
"recordDate": "2024-05-12"
"id": 160,
"createTime": "2024-05-12T20:00:12",
"recordDate": "2024-05-11"
How does it happen? I am confused.
New contributor
Mark X is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.