Skip to content

Instantly share code, notes, and snippets.

@nakamura-to
Created August 8, 2024 23:00
Show Gist options
  • Save nakamura-to/129723359c56ac7c055a91834ed3f6e4 to your computer and use it in GitHub Desktop.
Save nakamura-to/129723359c56ac7c055a91834ed3f6e4 to your computer and use it in GitHub Desktop.
Domaの複数行追加でonDuplicateKeyUpdate
@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