Hibernate version: 3.2
Name and version of the database you are using: DB2 9.5
In my original HIbernate project I wrote some code that explicitly used the Hibernate database connection to execute arbitrary SQL insert statement. I realize that is now deprecated so I am searching for a different way to do it. I know that I can use a Hibernate SQLQuery, but I think the performance may be poor compared to the JDBC version since I was using JDBC batching. For instance:
Code:
PreparedStatement insertSt = conn.prepareStatement("insert into foobar (foo, bar) values (?, ?)");
while (more) {
insertSt.clearParameters(0;
insertSt.setString(1, "blah blah");
insertSt.setString(2, "ha ha");
if (timeToInsert) {
insertSt.executeBatch();
conn.commit();
}
}
I am inserting ~1.6 million rows, executing the batch every 1000 rows.
Is there some way to do the equivalent in Hibernate? I have looked through the API for SQLQuery and Query and I have read the documentation and one aftermarket book pretty thoroughly, but have not seen anyone discuss this issue.
TIA.