u have to use batch processing for large data access from hibernate.
First set the jdbc.batch_size property to any number b/w 10 to 50 in hibernate.cfg.xml file.
if u r saving & update more no. of objects into DB. then check the loop index for batch size if it reaches that flush() and clear() the session.
Actually batch processing used for large number of objects accessing. for eg., if we r going to save 5000 users data without batch in middle of 1000 or some object the JVM show error Heap Memory Out exception.
for eg., how to use batch process for saving users object .
set jdbc.batch_size=30 in hibernate.cfg.xml file
for(int i=0;i<users.length;i++)
{
Users u =new Users();
u.setId(i);
....
if(i%30==0){
session.flush();
session.clear();
}
session.save(u); // session.update(u);
}
In this way we will deal with batch processing. it same procedure used in update also.
For more info.,
www.hibernate.org/hib_docs/reference/en/html/batch.html