norm icon indicating copy to clipboard operation
norm copied to clipboard

Batch operations

Open vicenrico opened this issue 4 years ago • 1 comments

Hello, I'd like to know how to create batch inserts or batch deletes with Norm. Is it that possible?

vicenrico avatar Apr 11 '21 15:04 vicenrico

There is no built-in support for it. I've been dropping into straight JDBC to do it.

Connection con = database.getConnection();
PreparedStatement myInserStatement = con.prepareStatement("insert into foo (id, bar) values (?,?)");
myInsertStatement.setInt(1, 1);
myInsertStatement.setString(2, "hello");
myInsertStatement.addBatch();
myInsertStatement.setInt(1, 2);
myInsertStatement.setString(2, "there");
myInsertStatement.addBatch();
myInsertStatement.executeBatch();
myInsertStatement.close();
con.close();

ccleve avatar Apr 12 '21 14:04 ccleve