I am newbie to Hibernate framework and I am curious about the way persist and update work.
Currently in my project when I would like to persist or update collection of data into database, I am doing it one by one via looping method. For instance,
public persistData(){
List<Person> personList = new ArrayList<>();
for(Person person : personList){
session.persist(person);
}
}
Is it possible to, for example,
session.persist(personList);
Or there is anyway else I can persist/update collection of data at once without looping?
Editted: I have found Hibernate Batch Processing in How to insert multiple rows into database using hibernate? and Best way to insert a good amount of records in hibernate
I am developing generic class for persist/update/delete data with hibernate, should I provide the method with
public void (List<T> addedItemList)
or
public void (T addedItem)
For my understanding, bulk persist should be done with large amount of transactions right? If some times there is only 1 or 2 objects to be persisted, is batch processing still appropriate?