BookAuthorRecord bookAuthorRecord = new BookAuthorRecord(1,1);
DSL.using(configuration).batchDelete(bookAuthorRecord).execute();
I get the below error:
Exception in thread "main" org.jooq.exception.DataAccessException: SQL [select `book_author`.`book_id`, `book_author`.`author_id` from `book_author` where (`book_author`.`book_id` = ? and `book_author`.`author_id` = ?) for update]; Can not issue executeUpdate() or executeLargeUpdate() for SELECTs at org.jooq.impl.Tools.translate(Tools.java:1941) at org.jooq.impl.DefaultExecuteContext.sqlException(DefaultExecuteContext.java:659) at org.jooq.impl.BatchSingle.executePrepared(BatchSingle.java:259) at org.jooq.impl.BatchSingle.execute(BatchSingle.java:182) at org.jooq.impl.BatchCRUD.executePrepared(BatchCRUD.java:159) at org.jooq.impl.BatchCRUD.execute(BatchCRUD.java:100) at com.jooq.JooqSampleTest.main(JooqSampleTest.java:37) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147) Caused by: java.sql.BatchUpdateException: Can not issue executeUpdate() or executeLargeUpdate() for SELECTs at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at com.mysql.jdbc.Util.handleNewInstance(Util.java:404) at com.mysql.jdbc.Util.getInstance(Util.java:387) at com.mysql.jdbc.SQLError.createBatchUpdateException(SQLError.java:1161) at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:1773) at com.mysql.jdbc.PreparedStatement.executeBatchInternal(PreparedStatement.java:1257) at com.mysql.jdbc.StatementImpl.executeBatch(StatementImpl.java:958) at org.jooq.tools.jdbc.DefaultStatement.executeBatch(DefaultStatement.java:93) at org.jooq.impl.BatchSingle.executePrepared(BatchSingle.java:239) ... 9 more Caused by: java.sql.SQLException: Can not issue executeUpdate() or executeLargeUpdate() for SELECTs at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:963) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:896) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:885) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:860) at com.mysql.jdbc.PreparedStatement.executeUpdateInternal(PreparedStatement.java:2045) at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:1751) ... 13 more
BookAuthorRecord bookAuthorRecord = new BookAuthorRecord(1,1);
bookAuthorRecord.attach(configuration);
bookAuthorRecord.refresh();
bookAuthorRecord.delete();
I would like to know how I can do bulk deletes for junction table which does not have the version column and I have configured optimistic
locking to true.
DSL.using(configuration).deleteFrom(BOOK_AUTHOR).where(BOOK_ID.eq(1)).and(AUTHOR_ID.eq(1)).execute();
--
You received this message because you are subscribed to the Google Groups "jOOQ User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jooq-user+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
RoleRecord roleRecord = new RoleRecord();
roleRecord.setName("role"); // name is the PK for this table
roleRecord.attach(configuration);
roleRecord.insert();
assertThat(roleRecord.getVersion()).isEqualTo(1);
assertThat(roleRecord.getDescription()).isNull();
roleRecord.setDescription("desc1");
DSL.using(configuration).batchUpdate(roleRecord).execute(); // this works fine as we have the most current roleRecord
RoleRecord fromDB = DSL.using(configuration).selectFrom(ROLE).where(ROLE.NAME.eq("role")).fetchOne();
assertThat(fromDB.getDescription()).isEqualTo("desc1");
assertThat(fromDB.getVersion()).isEqualTo(2);
roleRecord.setDescription("desc2");
DSL.using(configuration).batchUpdate(roleRecord).execute(); // does not throw DataChangedException, we have a stale roleRecord here
//roleRecord.update(); // throws a DataChangedException which is the correct behaviour
fromDB = DSL.using(configuration).selectFrom(ROLE).where(ROLE.NAME.eq("role")).fetchOne();
assertThat(fromDB.getVersion()).isEqualTo(3); // fails
assertThat(fromDB.getDescription()).isEqualTo("desc2"); // fails
To unsubscribe from this group and stop receiving emails from it, send an email to jooq-user+...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to jooq-user+unsubscribe@googlegroups.com.