File tree Expand file tree Collapse file tree 1 file changed +27
-1
lines changed
hibernate-core/src/test/java/org/hibernate/orm/test/stateless Expand file tree Collapse file tree 1 file changed +27
-1
lines changed Original file line number Diff line number Diff line change 1818
1919import static org .junit .jupiter .api .Assertions .assertDoesNotThrow ;
2020import static org .junit .jupiter .api .Assertions .assertEquals ;
21+ import static org .junit .jupiter .api .Assertions .assertNotNull ;
2122
2223@ SessionFactory (useCollectingStatementInspector = true )
23- @ DomainModel (annotatedClasses = UpsertTest .Record .class )
24+ @ DomainModel (annotatedClasses = { UpsertTest .Record .class , UpsertTest . IdOnly . class } )
2425public class UpsertTest {
2526 @ Test void test (SessionFactoryScope scope ) {
2627 scope .getSessionFactory ().getSchemaManager ().truncate ();
@@ -96,6 +97,19 @@ public class UpsertTest {
9697 scope .inStatelessTransaction (s -> assertDoesNotThrow (() -> s .upsert (new Record (123L ,null , null ))) );
9798 }
9899
100+ @ Test void testIdOnly (SessionFactoryScope scope ) {
101+ scope .getSessionFactory ().getSchemaManager ().truncate ();
102+
103+ scope .inStatelessTransaction (s -> {
104+ s .upsert (new IdOnly (123L ));
105+ s .upsert (new IdOnly (456L ));
106+ });
107+ scope .inStatelessTransaction (s -> {
108+ assertNotNull (s .get ( IdOnly .class ,123L ));
109+ assertNotNull (s .get ( IdOnly .class ,456L ));
110+ });
111+ }
112+
99113 @ Entity (name = "Record" )
100114 static class Record {
101115 @ Id Long id ;
@@ -116,4 +130,16 @@ static class Record {
116130 Record () {
117131 }
118132 }
133+
134+ @ Entity (name = "IdOnly" )
135+ static class IdOnly {
136+ @ Id Long id ;
137+
138+ IdOnly (Long id ) {
139+ this .id = id ;
140+ }
141+
142+ IdOnly () {
143+ }
144+ }
119145}
You can’t perform that action at this time.
0 commit comments