You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I hope this message finds you well. Thank you for your continued efforts in maintaining and improving MyBatis. I’d like to report an issue I’ve encountered and request your guidance on it.
Description:
When using MyBatis for an INSERT statement with foreach and ON DUPLICATE KEY UPDATE, the useGeneratedKeys option only generates keys for the first object in the list. Subsequent objects in the list do not have their generated keys populated. This issue significantly impacts batch operations that rely on the generated key values for further processing.
Enable useGeneratedKeys in the MyBatis configuration.
Pass a list of objects to the mapper method for insertion.
Expected Behavior: useGeneratedKeys should populate the generated keys for all objects in the list, not just the first one.
Actual Behavior:
Only the first object in the list receives its generated key value. The rest remain unpopulated.
Workaround:
Currently, there appears to be no straightforward workaround for this issue without either disabling ON DUPLICATE KEY UPDATE or implementing manual logic to retrieve the keys.
Additional Information:
This behavior might be related to how MyBatis processes batch inserts and how it retrieves the generated keys when ON DUPLICATE KEY UPDATE is involved.
Request:
Please investigate this issue and provide guidance or a fix. If additional information or a sample project is required, I can provide it.
Thank you!
The text was updated successfully, but these errors were encountered:
Dear MyBatis Team,
I hope this message finds you well. Thank you for your continued efforts in maintaining and improving MyBatis. I’d like to report an issue I’ve encountered and request your guidance on it.
Description:
When using MyBatis for an
INSERT
statement withforeach
andON DUPLICATE KEY UPDATE
, theuseGeneratedKeys
option only generates keys for the first object in the list. Subsequent objects in the list do not have their generated keys populated. This issue significantly impacts batch operations that rely on the generated key values for further processing.Environment:
Steps to Reproduce:
useGeneratedKeys
in the MyBatis configuration.Expected Behavior:
useGeneratedKeys
should populate the generated keys for all objects in the list, not just the first one.Actual Behavior:
Only the first object in the list receives its generated key value. The rest remain unpopulated.
Workaround:
Currently, there appears to be no straightforward workaround for this issue without either disabling
ON DUPLICATE KEY UPDATE
or implementing manual logic to retrieve the keys.Additional Information:
This behavior might be related to how MyBatis processes batch inserts and how it retrieves the generated keys when
ON DUPLICATE KEY UPDATE
is involved.Request:
Please investigate this issue and provide guidance or a fix. If additional information or a sample project is required, I can provide it.
Thank you!
The text was updated successfully, but these errors were encountered: