hibernate batch

Solutions on MaxInterview for hibernate batch by the best coders in the world

showing results for - "hibernate batch"
Alex
19 Aug 2020
1Session session = sessionFactory.openSession();
2Transaction tx = session.beginTransaction();
3
4ScrollableResults employeeCursor = session.createQuery("FROM EMPLOYEE").scroll();
5int count = 0;
6
7while ( employeeCursor.next() ) {
8   Employee employee = (Employee) employeeCursor.get(0);
9   employee.updateEmployee();
10   seession.update(employee); 
11   if ( ++count % 50 == 0 ) {
12      session.flush();
13      session.clear();
14   }
15}
16tx.commit();
17session.close();