简体   繁体   中英

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.

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);  

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM