Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Batch operations #54

Open
vicenrico opened this issue Apr 11, 2021 · 1 comment
Open

Batch operations #54

vicenrico opened this issue Apr 11, 2021 · 1 comment

Comments

@vicenrico
Copy link

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

@ccleve
Copy link
Member

ccleve commented Apr 12, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants