Hibernate version: 3.2
Hello all. I seem to get this very strange expception on my insert script:
Code:
org.hibernate.HibernateException: identifier of an instance of no.detnye.moteguiden.pojos.ProduktData was altered from 1165426136741 to 1165426136798
The strange thing is that my stack prints out and points some place in the code which has nothing to do with the ProduktData Pojo class.
Code:
at no.detnye.moteguiden.business.ForhandlerManagerImpl.getForhandlere(ForhandlerManagerImpl.java:164)
This code points to this:
Code:
public List getForhandlere() throws MoteguidenException {
Session session2 = HibernateUtil.getSessionFactory().getCurrentSession();
session2.beginTransaction();
Criteria criteria = session2.createCriteria(ForhandlerData.class);
criteria.addOrder(Order.asc("fnavn"));
return criteria.list();
}
Code:
at no.detnye.moteguiden.ImportGeneralTest.testStore(ImportGeneralTest.java:153)
And this code points to this:
Code:
List forhandlere = forhandlerMgr.getForhandlere();
The script works just fine when I begin and commit the transaction for every object I am trying to save. But this results in a big loss in resources as my scripts takes 8 minutes to run when I am just importing 500 lines of csv data in my database.
Code:
session = HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
session.save(object);
session.getTransaction().commit();
What I instead want is to beginTransaction at the start and commit when I am finished saving all objects.
Can someone please help me? I have read that you cannot use the same session on the two instances of the same Pojo class, meaning two instances of ProduktData. Maybe this is the case, although I cant really see where I am doing this. I will output the relevant code in next reply
Please help...