File tree Expand file tree Collapse file tree 2 files changed +62
-0
lines changed
ebean-test/src/test/java/org/tests/insert Expand file tree Collapse file tree 2 files changed +62
-0
lines changed Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff 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 () {
You can’t perform that action at this time.
0 commit comments