Skip to content

Commit 8c42a87

Browse files
committed
[#2398] Add test to show Mutation query with Joined Inheritance for databases supporting Global Temporary Tabels issue has been solved
1 parent 67fe139 commit 8c42a87

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

hibernate-reactive-core/src/test/java/org/hibernate/reactive/JoinedSubclassInheritanceTest.java

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
*/
66
package org.hibernate.reactive;
77

8+
import org.hibernate.reactive.annotations.DisabledFor;
9+
import org.hibernate.reactive.containers.DatabaseConfiguration;
10+
811
import org.junit.jupiter.api.Assertions;
912
import org.junit.jupiter.api.Test;
1013

@@ -28,6 +31,7 @@
2831

2932
import static java.util.concurrent.TimeUnit.MINUTES;
3033
import static org.assertj.core.api.Assertions.assertThat;
34+
import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.POSTGRESQL;
3135

3236
@Timeout(value = 10, timeUnit = MINUTES)
3337

@@ -185,6 +189,55 @@ public void testQueryUpdateWithParameters(VertxTestContext context) {
185189
);
186190
}
187191

192+
@Test
193+
@DisabledFor( value = POSTGRESQL, reason = "vertx-sql-client issue: https://github.com/eclipse-vertx/vertx-sql-client/issues/1540" )
194+
public void testHqlInsertWithTransaction(VertxTestContext context) {
195+
Integer id = 1;
196+
String title = "Spell Book: A Comprehensive Guide to Magic Spells and Incantations";
197+
test( context, getMutinySessionFactory()
198+
.withTransaction( session -> session.createMutationQuery( "insert into SpellBook (id, title, forbidden) values (:id, :title, :forbidden)" )
199+
.setParameter( "id", id )
200+
.setParameter( "title", title )
201+
.setParameter( "forbidden", true )
202+
.executeUpdate()
203+
).call( () -> getMutinySessionFactory()
204+
.withTransaction( session -> session.createSelectionQuery( "from SpellBook g where g.id = :id ", SpellBook.class )
205+
.setParameter( "id", id )
206+
.getSingleResult()
207+
.invoke( spellBook -> {
208+
assertThat( spellBook.getTitle() ).isEqualTo( title );
209+
assertThat( spellBook.forbidden ).isTrue();
210+
}
211+
)
212+
)
213+
)
214+
);
215+
}
216+
217+
@Test
218+
public void testHqlInsertWithoutTransaction(VertxTestContext context) {
219+
Integer id = 1;
220+
String title = "Spell Book: A Comprehensive Guide to Magic Spells and Incantations";
221+
test( context, getMutinySessionFactory()
222+
.withSession( session -> session.createMutationQuery( "insert into SpellBook (id, title, forbidden) values (:id, :title, :forbidden)" )
223+
.setParameter( "id", id )
224+
.setParameter( "title", title )
225+
.setParameter( "forbidden", true )
226+
.executeUpdate()
227+
).call( () -> getMutinySessionFactory()
228+
.withTransaction( session -> session.createSelectionQuery( "from SpellBook g where g.id = :id ", SpellBook.class )
229+
.setParameter( "id", id )
230+
.getSingleResult()
231+
.invoke( spellBook -> {
232+
assertThat( spellBook.getTitle() ).isEqualTo( title );
233+
assertThat( spellBook.forbidden ).isTrue();
234+
}
235+
)
236+
)
237+
)
238+
);
239+
}
240+
188241
@Entity(name="SpellBook")
189242
@Table(name = "SpellBookJS")
190243
@DiscriminatorValue("S")

0 commit comments

Comments
 (0)