Lalit Bhudiya
Lalit Bhudiya

Reputation: 4418

May i save multiple records at a time in Hibernate?

I have List of particular class. I want to save this List at a time without loop using Hibernate Transaction. Is it possible ?

Suppose i have a class

 Class a{
    private int no;
    private String name;

    public getNo(){
    return this.no;
    }
    public setNo(int no){
    this.no=no;
    }
    public getName(){
    return this.name;
    }
    public setName(String name){
    this.name=name;
    }
}

now i have

List<a> list;

so i can save list directly without looping? If yes, than please help me.

Upvotes: 1

Views: 2514

Answers (1)

Yogesh Prajapati
Yogesh Prajapati

Reputation: 4870

you can do this without loop

for that you need to use spring's hibernate utility

that utility like

getHibernateTemplate().saveOrUpdateAll(questionsCollection);  

or

getHibernateTemplate().deleteAll(questionsCollection);  

Upvotes: 3

Related Questions