Hi All, I have a batch process which updates two tables in a for loop as shown in the below code snippet.The size of the marsInvoiceDAOList is 30,079 and all records are updated except two giving the error mentioned in the subject line. I am trying to update thousands of duplicate records to the two tables. If I dont put the code in REd color then I used to get the org.hibernate.NonUniqueObjectxception.A different object with the same identifier value was already associated with the session. ... BhrvInvoiceDAO bhrvInv = new BhrvInvoiceDAO(); int indx=0; for(MarsInvoiceDAO mars : marsInvoiceDAOList) { this.getSession.update(mars); bhrvInv = getBhrvInvoiceDAO(mars.getBhrvInvoiceId); bhrvInv.setProcessStatusCode(5); this.getSession.update(bhrv); indx++; if(indx % 20 == 0) { this.getSession.flush(); this.getSession.clear(); } }
I have mentioned the batch_size as 20 and second level cache as false in the hibernate config file.
I am unable to understand why only two records out of 30,079 fail and why?
Any help is higly appreciated.
|