提问人:Jyoti Pandey 提问时间:11/9/2023 最后编辑:nageenJyoti Pandey 更新时间:11/9/2023 访问量:23
未上传,因为 (conn=4254387) 键“PRIMARY”的重复条目“1097894”;第 2 行发生异常
NOT UPLOADED BECAUSE (conn=4254387) Duplicate entry '1097894' for key 'PRIMARY' ; EXCEPTION OCCURED ON ROW NO. 2
问:
我正在该文件中上传 excel 文件,我有数据可以正确获取,但在保存它时显示我的 hrpayroll 主键中有一个错误,该主键为 2 个条目正确生成,但在审计表中,它对两个条目的主键具有相同的 id no,这引发了错误,为什么发生没有得到
如果我正在执行 2 个条目,我想要那个 hrpayroll 表,那么 hrpayroll 审计表中应该有 2 个具有唯一 id 的条目
。内部。SessionImpl) SessionImpl(PersistenceContext[entityKeys=[EntityKey[com.pladatechnologies.entity.AuditEntity#1097891], 实体密钥[com.pladatechnologies.merchantworld.entity.HrPayRoll#310], 实体密钥[com.pladatechnologies.merchantworld.entity.HrPayRoll#311], EntityKey[com.pladatechnologies.merchantworld.entity.HrPayRoll_AUD#component[hrid,REV]{REV=com.pladatechnologies.entity.AuditEntity#1097891, hrid=311}], EntityKey[com.pladatechnologies.merchantworld.entity.HrPayRoll_AUD#component[hrid,REV]{REV=com.pladatechnologies.entity.AuditEntity#1097891, hrid=310}]],collectionKeys=[]];ActionQueue[insertions=[EntityInsertAction[com.pladatechnologies.merchantworld.entity.HrPayRoll_AUD#{REV=DefaultRevisionEntity(id = 1097891, revisionDate = 2023 年 11 月 9 日上午 10:35:18), hrid=310}], EntityInsertAction[com.pladatechnologies.merchantworld.entity.HrPayRoll_AUD#{REV=DefaultRevisionEntity(id = 1097891, revisionDate = 2023 年 11 月 9 日上午 10:35:18), hrid=311}]] updates=[] deletions=[] orphanRemovals=[] collectionCreations=[] collectionRemovals=[] collectionUpdates=[] collectionQueuedOps=[] unresolvedInsertDependencies=UnresolvedEntityInsertActions[]])
@Override
public String pushToDB(List<Entity> pEntityList) throws SystemException {
logger.entry();
Session session = getSessionFactory().openSession();
Transaction tx = session.beginTransaction();
String filestatus = "";
int j = 0;
try {
for (Iterator<Entity> it = pEntityList.iterator(); it.hasNext();) {
HrPayRoll lTHr = (HrPayRoll) it.next();
j++;
session.evict(lTHr);
session.save(lTHr);
if (j % 300 == 0) {
session.flush();
session.clear();
}
}
tx.commit();
session.flush();
filestatus = "PROCESSED SUCCESSFULLY";
} catch (HibernateException e) {
if (tx != null) {
tx.rollback();
}
filestatus = "NOT UPLOADED BECAUSE " + e.getCause().getMessage() + " ; EXCEPTION OCCURED ON ROW NO. " + j;
return filestatus;
} finally {
if (session != null && session.isOpen()) {
session.close();
}
}
logger.exit();
return filestatus;
}
答: 暂无答案
评论