Previously i was not getting any error but suddenly i am started getting error :
javax.persistence.EntityExistsException: A different object with the same identifier value was already associated with the session : [baag.betl.dbimporter.esmatrans.db.EquSecurityReferenceData#baag.db.SECU@59c70ceb]
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:116) ~[hibernate-core-5.2.10.Final.jar:5.2.10.Final]
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:155) ~[hibernate-core-5.2.10.Final.jar:5.2.10.Final]
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:162) ~[hibernate-core-5.2.10.Final.jar:5.2.10.Final]
at org.hibernate.internal.SessionImpl.firePersist(SessionImpl.java:787) ~[hibernate-core-5.2.10.Final.jar:5.2.10.Final]
at org.hibernate.internal.SessionImpl.persist(SessionImpl.java:765) ~[hibernate-core-5.2.10.Final.jar:5.2.10.Final]
There is no sequence created for any column in oracle database table. Also there is combination of unique key column for esn and techid. I dont want to create new sequence column in my database table.
I think i cannot use @GeneratedValue and set it to Auto for unique columns otherwise i will get hibernate sequence error.
I am also doing clear and flush after every 1000 records processed.
if (secuData != null) {
sessionFactory.getCurrentSession().persist(secuData);
}
i++;
if (i % 1000 == 0) {
sessionFactory.getCurrentSession().flush();
sessionFactory.getCurrentSession().clear();
}