I am uploading excel file in that file I having data that is getting properly but while saving it showing me an error in my hrpayroll primary key which is generating properly for 2 entries but in the audit table it has the same id no for the primary key for both entry which is throwing error why does happening not getting
I want that hrpayroll table if I am doing 2 entries then there should be 2 entries with unique id in hrpayroll audit table
.internal.SessionImpl) SessionImpl(PersistenceContext[entityKeys=[EntityKey[com.pladatechnologies.entity.AuditEntity#1097891], EntityKey[com.pladatechnologies.merchantworld.entity.HrPayRoll#310], EntityKey[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 = 9 Nov, 2023 10:35:18 AM), hrid=310}], EntityInsertAction[com.pladatechnologies.merchantworld.entity.HrPayRoll_AUD#{REV=DefaultRevisionEntity(id = 1097891, revisionDate = 9 Nov, 2023 10:35:18 AM), 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;
}