我需要使用Hibernate更新MySQL数据库中的多行。我使用JDBC完成了这项工作,我们得到了批量查询的支持。在hibernate中我想要这样的东西。
hibernate是否支持批量查询?
jdbc中的批处理查询示例:
// Create statement object
Statement stmt = conn.createStatement();
String SQL = "INSERT INTO Employees (id, first, last, age) " +
"VALUES(200,'Zia', 'Ali', 30)";
// Add above SQL statement in the batch.
stmt.addBatch(SQL);
// Create one more SQL statement
String SQL = "INSERT INTO Employees (id, first, last, age) " +
"VALUES(201,'Raj', 'Kumar', 35)";
// Add above SQL statement in the batch.
stmt.addBatch(SQL);
int[] count = stmt.executeBatch();
现在当我们发出stmt.executeBatch调用时,两个Sql Query都将在单个jdbc往返中执行。