Skip to content

Commit a311e38

Browse files
geoandDavideD
authored andcommitted
Fix FetchedAssociationTest
The assertion of the test needed to updated to the ORM 6 generated queries (the queries as essentially the same, but the sequences and names of variables have changed). Furthermore, the custom cleanup is done because the actual test itself passes (with the updated assertion), but the DB clearing fails because of the association loading issue.
1 parent cd6744d commit a311e38

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

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

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.hibernate.reactive.testing.DatabaseSelectionRule;
2424
import org.hibernate.reactive.testing.SqlStatementTracker;
2525

26+
import org.junit.After;
2627
import org.junit.Rule;
2728
import org.junit.Test;
2829

@@ -53,6 +54,13 @@ protected Configuration constructConfiguration() {
5354
return configuration;
5455
}
5556

57+
@After
58+
public void cleanDb(TestContext context) {
59+
test( context, getSessionFactory()
60+
.withTransaction( s -> s.createQuery( "delete from Child" ).executeUpdate()
61+
.thenCompose( v -> s.createQuery( "delete from Parent" ).executeUpdate() ) ) );
62+
}
63+
5664
private static boolean isSelectOrInsertQuery(String s) {
5765
return s.toLowerCase().startsWith( "select" )
5866
|| s.toLowerCase().startsWith( "insert" );
@@ -92,11 +100,11 @@ public void testWithMutiny(TestContext context) {
92100
// We don't expect a select from CHILD
93101
private String[] getExpectedNativeQueries() {
94102
return new String[] {
95-
"select nextval ('hibernate_sequence')",
96-
"insert into PARENT (name, id) values ($1, $2)",
97-
"select fetchedass0_.id as id1_1_, fetchedass0_.name as name2_1_ from PARENT fetchedass0_",
98-
"select nextval ('hibernate_sequence')",
99-
"insert into CHILD (name, lazy_parent_id, id) values ($1, $2, $3)"
103+
"select nextval('PARENT_SEQ')",
104+
"insert into PARENT (name,id) values ($1,$2)",
105+
"select p1_0.id,p1_0.name from PARENT p1_0",
106+
"select nextval('CHILD_SEQ')",
107+
"insert into CHILD (name,lazy_parent_id,id) values ($1,$2,$3)"
100108
};
101109
}
102110

0 commit comments

Comments
 (0)