Skip to content

Commit f92c2f8

Browse files
committed
Test only - add test for string id InsertOnConflict
1 parent 51c3065 commit f92c2f8

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package org.tests.insert;
2+
3+
import jakarta.persistence.Entity;
4+
import jakarta.persistence.Id;
5+
import jakarta.persistence.Version;
6+
7+
@Entity
8+
public class EStrIdBean {
9+
10+
@Id
11+
String id;
12+
13+
@Version
14+
long version; // = 1;
15+
16+
private String name;
17+
18+
public String id() {
19+
return id;
20+
}
21+
22+
public EStrIdBean setId(String id) {
23+
this.id = id;
24+
return this;
25+
}
26+
27+
public long version() {
28+
return version;
29+
}
30+
31+
public EStrIdBean setVersion(long version) {
32+
this.version = version;
33+
return this;
34+
}
35+
36+
public String name() {
37+
return name;
38+
}
39+
40+
public EStrIdBean setName(String name) {
41+
this.name = name;
42+
return this;
43+
}
44+
}

ebean-test/src/test/java/org/tests/insert/TestInsertOnConflict.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,24 @@ class TestInsertOnConflict extends BaseTestCase {
2525
.getGeneratedKeys(true)
2626
.build();
2727

28+
@ForPlatform({Platform.POSTGRES, Platform.YUGABYTE})
29+
@Test
30+
void insertTestEntity() {
31+
var entity1 = new EStrIdBean();
32+
entity1.setId("entity-1");
33+
entity1.setName("Example");
34+
DB.insert(entity1);
35+
36+
var entity2 = new EStrIdBean();
37+
entity2.setId("entity-1");
38+
entity2.setName("Example");
39+
40+
DB.getDefault().insert(entity2, InsertOptions.builder()
41+
.onConflictNothing()
42+
.uniqueColumns("id")
43+
.build());
44+
}
45+
2846
@ForPlatform({Platform.POSTGRES, Platform.YUGABYTE})
2947
@Test
3048
void insertOnConflictUpdateExplicitTransaction() {

0 commit comments

Comments
 (0)