HHH-4299 - Add test for issue

Signed-off-by: Jan Schatteman <jschatte@redhat.com>

# Conflicts:
#	hibernate-core/src/test/java/org/hibernate/orm/test/annotations/embeddables/EmbeddableWithGenericAndMappedSuperClassTest.java
This commit is contained in:
Jan Schatteman 2023-01-26 22:53:12 +01:00 committed by Christian Beikov
parent b6eaffeb29
commit c7074d5ac9
1 changed files with 18 additions and 3 deletions

View File

@ -6,7 +6,8 @@ import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.orm.junit.DomainModel;
import org.hibernate.testing.orm.junit.SessionFactory;
import org.hibernate.testing.orm.junit.SessionFactoryScope;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import jakarta.persistence.Column;
@ -24,7 +25,8 @@ import static org.assertj.core.api.Assertions.assertThat;
@DomainModel(
annotatedClasses = {
EmbeddableWithGenericAndMappedSuperClassTest.PopularBook.class,
EmbeddableWithGenericAndMappedSuperClassTest.RareBook.class
EmbeddableWithGenericAndMappedSuperClassTest.RareBook.class,
EmbeddableWithGenericAndMappedSuperClassTest.GenericExample.class
}
)
@SessionFactory
@ -35,7 +37,7 @@ public class EmbeddableWithGenericAndMappedSuperClassTest {
private final static long RARE_BOOK_ID = 2l;
private final static Integer RARE_BOOK_CODE = 123;
@BeforeEach
@BeforeAll
public void setUp(SessionFactoryScope scope) {
scope.inTransaction(
session -> {
@ -47,6 +49,19 @@ public class EmbeddableWithGenericAndMappedSuperClassTest {
session.persist( popularBook );
session.persist( rareBook );
session.persist( new GenericExample(1, new Range<>(2, 3)) );
}
);
}
@AfterAll
public void tearDown(SessionFactoryScope scope) {
scope.inTransaction(
session -> {
session.createMutationQuery( "delete from PopularBook" ).executeUpdate();
session.createMutationQuery( "delete from RareBook" ).executeUpdate();
session.createMutationQuery( "delete from GenericExample" ).executeUpdate();
}
);
}