If you do not need to worry about SQL injection. that is, you do not receive data from the user, then you can do it.
StringBuilder sqlInsert = new StringBuilder("insert into sampletbl (name) values "); for(String name : list){ sqlInsert.append("("+name++"),"); } sqlInsert.setLength(sqlInsert.length() - 1); session.createSQLQuery( sqlInsert.toString()).executeUpdate();
He will create such a request.
insert into sampletbl (name) values ("name1"), ("name2")....
Thus, your request will be launched only once, and not for each item in the list.
source share