I want to save multiple records in DB using Hibernate.I m succeeded in that.But thinking my approach is wrong.Since If records increases it will create performance prob.
I want to store in DB like,
FirstName LastName
FNameABC LNameCC
FNamePQR LNameDD
FNameXYZ LNameEE
I stored the above values in DB as,
Iterator itr = list.Iterator();
while(itr.hasNext()) {
Test t = (Test)itr.next();
dbEntity.setFirstName(t.setFirstName());
dbEntity.setLastName(t.setLastName());
session.beginTransaction();
session.save(dbEntity);
session.getTransaction().commit();
session.close();
}
Here I'm saving the value in the seession inside a loop. So every time for each record it will call beginTransaction(), save(), commit().
Is there any better approach ?