Skip to content

Commit 78fbd92

Browse files
committed
Add validation to UpsertAssemblerContext
1 parent 5ee64d4 commit 78fbd92

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

doma-core/src/main/java/org/seasar/doma/jdbc/query/UpsertAssemblerContext.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,16 @@ public UpsertAssemblerContext(
5050
"duplicateKeyType",
5151
"The duplicateKeyType must not be set to EXCEPTION when performing an upsert.");
5252
}
53+
if (keys.isEmpty()) {
54+
throw new DomaIllegalArgumentException(
55+
"keys",
56+
"The keys must not be empty when performing an upsert. At least one key must be specified.");
57+
}
58+
if (duplicateKeyType == DuplicateKeyType.UPDATE && setValues.isEmpty()) {
59+
throw new DomaIllegalArgumentException(
60+
"setValues",
61+
"The setValues must not be empty when performing an upsert with the UPDATE duplicateKeyType. At least one set value must be specified.");
62+
}
5363
this.buf = buf;
5464
this.entityType = entityType;
5565
this.duplicateKeyType = duplicateKeyType;

0 commit comments

Comments
 (0)