mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-16 16:15:06 +00:00
Restrict enum tests on column checks based on dialect support
This commit is contained in:
parent
5a111c8fbb
commit
921d59ee8b
@ -15,7 +15,10 @@
|
||||
import org.hibernate.orm.test.mapping.enumeratedvalue.EnumeratedValueTests;
|
||||
import org.hibernate.type.SqlTypes;
|
||||
|
||||
import org.hibernate.testing.orm.junit.DialectFeatureCheck;
|
||||
import org.hibernate.testing.orm.junit.DialectFeatureChecks;
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.RequiresDialectFeature;
|
||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||
import org.hibernate.testing.orm.junit.SessionFactoryScope;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
@ -79,15 +82,16 @@ void testNulls(SessionFactoryScope scope) {
|
||||
} );
|
||||
}
|
||||
|
||||
@DomainModel(annotatedClasses = EnumeratedValueTests.Person.class)
|
||||
@DomainModel(annotatedClasses = Person.class)
|
||||
@SessionFactory(useCollectingStatementInspector = true)
|
||||
@RequiresDialectFeature( feature = DialectFeatureChecks.SupportsColumnCheck.class )
|
||||
@Test
|
||||
void verifyCheckConstraints(SessionFactoryScope scope) {
|
||||
scope.inTransaction( (session) -> session.doWork( (connection) -> {
|
||||
try (PreparedStatement statement = connection.prepareStatement( "insert into persons (id, gender) values (?, ?)" ) ) {
|
||||
statement.setInt( 1, 100 );
|
||||
// this would work without check constraints or with check constraints based solely on EnumType#STRING
|
||||
statement.setString( 2, "MALE" );
|
||||
statement.setString( 2, "A" );
|
||||
statement.executeUpdate();
|
||||
fail( "Expecting a failure" );
|
||||
}
|
||||
|
@ -15,7 +15,9 @@
|
||||
import org.hibernate.dialect.SybaseDialect;
|
||||
import org.hibernate.type.SqlTypes;
|
||||
|
||||
import org.hibernate.testing.orm.junit.DialectFeatureChecks;
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.RequiresDialectFeature;
|
||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||
import org.hibernate.testing.orm.junit.SessionFactoryScope;
|
||||
import org.hibernate.testing.orm.junit.SkipForDialect;
|
||||
@ -86,6 +88,7 @@ void testNulls(SessionFactoryScope scope) {
|
||||
|
||||
@DomainModel(annotatedClasses = Person.class)
|
||||
@SessionFactory
|
||||
@RequiresDialectFeature( feature = DialectFeatureChecks.SupportsColumnCheck.class )
|
||||
@Test
|
||||
void verifyCheckConstraints(SessionFactoryScope scope) {
|
||||
scope.inTransaction( (session) -> session.doWork( (connection) -> {
|
||||
@ -103,6 +106,7 @@ void verifyCheckConstraints(SessionFactoryScope scope) {
|
||||
@DomainModel(annotatedClasses = Person.class)
|
||||
@SessionFactory
|
||||
@SkipForDialect( dialectClass = SybaseDialect.class, matchSubTypes = true, reason = "Sybase (at least jTDS driver) truncates the value so the constraint is not violated" )
|
||||
@RequiresDialectFeature( feature = DialectFeatureChecks.SupportsColumnCheck.class )
|
||||
@Test
|
||||
void verifyCheckConstraints2(SessionFactoryScope scope) {
|
||||
scope.inTransaction( (session) -> session.doWork( (connection) -> {
|
||||
|
@ -12,7 +12,9 @@
|
||||
import java.sql.Statement;
|
||||
|
||||
import org.hibernate.testing.jdbc.SQLStatementInspector;
|
||||
import org.hibernate.testing.orm.junit.DialectFeatureChecks;
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.RequiresDialectFeature;
|
||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||
import org.hibernate.testing.orm.junit.SessionFactoryScope;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
@ -85,6 +87,7 @@ void testNulls(SessionFactoryScope scope) {
|
||||
|
||||
@DomainModel(annotatedClasses = Person.class)
|
||||
@SessionFactory(useCollectingStatementInspector = true)
|
||||
@RequiresDialectFeature( feature = DialectFeatureChecks.SupportsColumnCheck.class )
|
||||
@Test
|
||||
void verifyCheckConstraints(SessionFactoryScope scope) {
|
||||
scope.inTransaction( (session) -> session.doWork( (connection) -> {
|
||||
|
Loading…
x
Reference in New Issue
Block a user