Created
August 8, 2024 23:00
-
-
Save nakamura-to/129723359c56ac7c055a91834ed3f6e4 to your computer and use it in GitHub Desktop.
Domaの複数行追加でonDuplicateKeyUpdate
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Dao | |
public interface DeptDao { | |
@MultiInsert(duplicateKeyType = DuplicateKeyType.UPDATE) | |
int insertOnDuplicateKeyUpdate(List<Dept> entities); | |
} | |
``` | |
insert into DEPARTMENT as target ( | |
DEPARTMENT_ID, | |
DEPARTMENT_NO, | |
DEPARTMENT_NAME, | |
LOCATION, | |
VERSION | |
) | |
values | |
(?, ?, ?, ?, ?), | |
(?, ?, ?, ?, ?) | |
on conflict | |
(DEPARTMENT_ID) | |
do update set | |
DEPARTMENT_NO = excluded.DEPARTMENT_NO, | |
DEPARTMENT_NAME = excluded.DEPARTMENT_NAME, | |
LOCATION = excluded.LOCATION, | |
VERSION = excluded.VERSION | |
``` | |
@Dao | |
public interface DeptDao { | |
@MultiInsert(duplicateKeyType = DuplicateKeyType.UPDATE, duplicateKeys = {"departmentNo"}) | |
int insertOnDuplicateKeyUpdate(List<Dept> entities); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment