Closed Petitt88 closed 1 year ago
Is this reproducible for any size of newUsers
?
There is batchInsert test for every DBMS and no problem with Oracle.
Could it happen when you try to insert userName which already exists in DB?
Hello @Tapac, I faced with the same issue and investigated this bug a little bit. Oracle driver doesn't like executeBatch with PreparedStatement.RETURN_GENERATED_KEYS. ojdbc6 (11.2.0.3 and 11.2.0.4 versions) throw OOB exception on any batch size > 1, ojdbc7 (12.1.0.2) doesn't work on batches with size > 10 (It depends on CONNECTION_PROPERTY_DEFAULT_ROW_PREFETCH_DEFAULT). ojdbc8 (12.2.0.1) works well, but returned list of columns contains only empty hashmaps and can't be used as list of generated keys.
8th version should solve problem with batchInsert in case where generated keys are not required. At least it supports all latest version of oracle db.
All versions was tested on windows against oracle 11g db.
@HirumaStu , thank you for your detailed investigation. So if I understand properly batchInsert
implementation for Oracle should depend on jdbc version and CONNECTION_PROPERTY_DEFAULT_ROW_PREFETCH_DEFAULT property value? And if it doesn't support returning generated keys then it should be replaced with a simple insert
?
@HirumaStu , thank you for your detailed investigation. So if I understand properly
batchInsert
implementation for Oracle should depend on jdbc version and CONNECTION_PROPERTY_DEFAULT_ROW_PREFETCH_DEFAULT property value? And if it doesn't support returning generated keys then it should be replaced with a simpleinsert
?
Hey @Petitt88 @HirumaStu , any thoughts on the above?
I have a fairly simple Users table, it looks like this:
The schema has to 2 more tables in relation to the Users table: Roles and UserRoles:
When I try to batchinsert (in my case 156 user records into the users table) I get this exception:
If I do a normal insert in a for loop
Users.insert {...}
- it works.