Hi,
We are using Hibernate3. We have a set of hibernate object(of same type) which we are saving something like:
Code:
while(someCondition) {
MyHibernateObject obj = MyUtil.createHO();
//save the object. This save API is called as part of the loop
getCurrentSession().save(MyHibernateObject.class.getName(),obj);
}
Is there an better way to do this? Is there some way by which i can pass my set of objects(of the same type) to be saved in one go? Some thing like bulk insert?
My code would look like:
Code:
Set myHOs = new HashSet();
while(someCondition) {
MyHibernateObject obj = MyUtil.createHO();
//just add the object to a Set, to save later in one go
myHOs.add(obj);
} //end of loop
//save all the objects, that were created earlier, in one go
getCurrentSession().save(MyHibernateObject.class.getName(),myHOs);
The reason i am trying this approach is to improve the performance.
Any help is appreciated.