Adapt tests and skips for H2 2.0.202+
This commit is contained in:
parent
6feb33f4e1
commit
fb749b6b32
|
@ -23,33 +23,32 @@ import jakarta.persistence.criteria.Root;
|
||||||
import org.hibernate.annotations.ColumnTransformer;
|
import org.hibernate.annotations.ColumnTransformer;
|
||||||
import org.hibernate.annotations.NaturalId;
|
import org.hibernate.annotations.NaturalId;
|
||||||
import org.hibernate.dialect.H2Dialect;
|
import org.hibernate.dialect.H2Dialect;
|
||||||
import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase;
|
|
||||||
|
|
||||||
import org.hibernate.testing.RequiresDialect;
|
import org.hibernate.testing.orm.junit.EntityManagerFactoryScope;
|
||||||
import org.junit.Test;
|
import org.hibernate.testing.orm.junit.Jpa;
|
||||||
|
import org.hibernate.testing.orm.junit.RequiresDialect;
|
||||||
|
import org.hibernate.testing.orm.junit.SkipForDialect;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Vlad Mihalcea
|
* @author Vlad Mihalcea
|
||||||
*/
|
*/
|
||||||
|
@Jpa(annotatedClasses = {
|
||||||
|
FetchingTest.Department.class,
|
||||||
|
FetchingTest.Employee.class,
|
||||||
|
FetchingTest.Project.class
|
||||||
|
})
|
||||||
@RequiresDialect(H2Dialect.class)
|
@RequiresDialect(H2Dialect.class)
|
||||||
public class FetchingTest extends BaseEntityManagerFunctionalTestCase {
|
@SkipForDialect(dialectClass = H2Dialect.class, majorVersion = 2, matchSubTypes = true, reason = "See https://github.com/h2database/h2database/issues/3338")
|
||||||
|
public class FetchingTest {
|
||||||
@Override
|
|
||||||
protected Class<?>[] getAnnotatedClasses() {
|
|
||||||
return new Class<?>[] {
|
|
||||||
Department.class,
|
|
||||||
Employee.class,
|
|
||||||
Project.class
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() {
|
public void test(EntityManagerFactoryScope scope) {
|
||||||
doInJPA(this::entityManagerFactory, entityManager -> {
|
scope.inTransaction( entityManager -> {
|
||||||
Department department = new Department();
|
Department department = new Department();
|
||||||
department.id = 1L;
|
department.id = 1L;
|
||||||
entityManager.persist(department);
|
entityManager.persist(department);
|
||||||
|
@ -72,7 +71,7 @@ public class FetchingTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
doInJPA(this::entityManagerFactory, entityManager -> {
|
scope.inTransaction( entityManager -> {
|
||||||
String username = "user1";
|
String username = "user1";
|
||||||
String password = "3fabb4de8f1ee2e97d7793bab2db1116";
|
String password = "3fabb4de8f1ee2e97d7793bab2db1116";
|
||||||
//tag::fetching-strategies-no-fetching-example[]
|
//tag::fetching-strategies-no-fetching-example[]
|
||||||
|
@ -90,7 +89,7 @@ public class FetchingTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
assertNotNull(employee);
|
assertNotNull(employee);
|
||||||
});
|
});
|
||||||
|
|
||||||
doInJPA(this::entityManagerFactory, entityManager -> {
|
scope.inTransaction( entityManager -> {
|
||||||
String username = "user1";
|
String username = "user1";
|
||||||
String password = "3fabb4de8f1ee2e97d7793bab2db1116";
|
String password = "3fabb4de8f1ee2e97d7793bab2db1116";
|
||||||
//tag::fetching-strategies-no-fetching-scalar-example[]
|
//tag::fetching-strategies-no-fetching-scalar-example[]
|
||||||
|
@ -108,7 +107,7 @@ public class FetchingTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
assertEquals(Integer.valueOf(0), accessLevel);
|
assertEquals(Integer.valueOf(0), accessLevel);
|
||||||
});
|
});
|
||||||
|
|
||||||
doInJPA(this::entityManagerFactory, entityManager -> {
|
scope.inTransaction( entityManager -> {
|
||||||
String username = "user1";
|
String username = "user1";
|
||||||
String password = "3fabb4de8f1ee2e97d7793bab2db1116";
|
String password = "3fabb4de8f1ee2e97d7793bab2db1116";
|
||||||
//tag::fetching-strategies-dynamic-fetching-jpql-example[]
|
//tag::fetching-strategies-dynamic-fetching-jpql-example[]
|
||||||
|
@ -127,7 +126,7 @@ public class FetchingTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
assertNotNull(employee);
|
assertNotNull(employee);
|
||||||
});
|
});
|
||||||
|
|
||||||
doInJPA(this::entityManagerFactory, entityManager -> {
|
scope.inTransaction( entityManager -> {
|
||||||
String username = "user1";
|
String username = "user1";
|
||||||
String password = "3fabb4de8f1ee2e97d7793bab2db1116";
|
String password = "3fabb4de8f1ee2e97d7793bab2db1116";
|
||||||
//tag::fetching-strategies-dynamic-fetching-criteria-example[]
|
//tag::fetching-strategies-dynamic-fetching-criteria-example[]
|
||||||
|
@ -176,6 +175,12 @@ public class FetchingTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
read = "decrypt('AES', '00', pswd )",
|
read = "decrypt('AES', '00', pswd )",
|
||||||
write = "encrypt('AES', '00', ?)"
|
write = "encrypt('AES', '00', ?)"
|
||||||
)
|
)
|
||||||
|
// For H2 2.0.202+ one must use the varbinary DDL type
|
||||||
|
// @Column(name = "pswd", columnDefinition = "varbinary")
|
||||||
|
// @ColumnTransformer(
|
||||||
|
// read = "trim(trailing u&'\\0000' from cast(decrypt('AES', '00', pswd ) as character varying))",
|
||||||
|
// write = "encrypt('AES', '00', ?)"
|
||||||
|
// )
|
||||||
private String password;
|
private String password;
|
||||||
|
|
||||||
private int accessLevel;
|
private int accessLevel;
|
||||||
|
|
|
@ -6,13 +6,6 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.orm.test.jpa.procedure;
|
package org.hibernate.orm.test.jpa.procedure;
|
||||||
|
|
||||||
import jakarta.persistence.Entity;
|
|
||||||
import jakarta.persistence.EntityManager;
|
|
||||||
import jakarta.persistence.Id;
|
|
||||||
import jakarta.persistence.Parameter;
|
|
||||||
import jakarta.persistence.ParameterMode;
|
|
||||||
import jakarta.persistence.StoredProcedureQuery;
|
|
||||||
import jakarta.persistence.Table;
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
@ -20,13 +13,20 @@ import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.hibernate.dialect.H2Dialect;
|
import org.hibernate.dialect.H2Dialect;
|
||||||
import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase;
|
|
||||||
|
|
||||||
import org.junit.After;
|
import org.hibernate.testing.orm.junit.EntityManagerFactoryScope;
|
||||||
import org.junit.Before;
|
import org.hibernate.testing.orm.junit.Jpa;
|
||||||
import org.junit.Test;
|
import org.hibernate.testing.orm.junit.RequiresDialect;
|
||||||
|
import org.junit.jupiter.api.AfterAll;
|
||||||
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import org.hibernate.testing.RequiresDialect;
|
import jakarta.persistence.Entity;
|
||||||
|
import jakarta.persistence.Id;
|
||||||
|
import jakarta.persistence.Parameter;
|
||||||
|
import jakarta.persistence.ParameterMode;
|
||||||
|
import jakarta.persistence.StoredProcedureQuery;
|
||||||
|
import jakarta.persistence.Table;
|
||||||
|
|
||||||
import static org.hamcrest.core.Is.is;
|
import static org.hamcrest.core.Is.is;
|
||||||
import static org.hamcrest.core.IsNot.not;
|
import static org.hamcrest.core.IsNot.not;
|
||||||
|
@ -37,60 +37,35 @@ import static org.junit.Assert.fail;
|
||||||
/**
|
/**
|
||||||
* @author Andrea Boriero
|
* @author Andrea Boriero
|
||||||
*/
|
*/
|
||||||
|
@Jpa( annotatedClasses = H2StoreProcedureTest.MyEntity.class)
|
||||||
@RequiresDialect(H2Dialect.class)
|
@RequiresDialect(H2Dialect.class)
|
||||||
public class H2StoreProcedureTest extends BaseEntityManagerFunctionalTestCase {
|
public class H2StoreProcedureTest {
|
||||||
@Override
|
|
||||||
protected Class<?>[] getAnnotatedClasses() {
|
@BeforeAll
|
||||||
return new Class<?>[] {MyEntity.class};
|
public void setUp(EntityManagerFactoryScope scope) {
|
||||||
|
scope.inTransaction(
|
||||||
|
entityManager -> {
|
||||||
|
entityManager.createNativeQuery( "CREATE ALIAS get_all_entities FOR \"" + H2StoreProcedureTest.class.getCanonicalName() + ".getAllEntities\";" )
|
||||||
|
.executeUpdate();
|
||||||
|
|
||||||
|
entityManager.createNativeQuery( "CREATE ALIAS by_id FOR \"" + H2StoreProcedureTest.class.getCanonicalName() + ".entityById\";" )
|
||||||
|
.executeUpdate();
|
||||||
|
MyEntity entity = new MyEntity();
|
||||||
|
entity.id = 1;
|
||||||
|
entity.name = "entity1";
|
||||||
|
entityManager.persist( entity );
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Before
|
@AfterAll
|
||||||
public void setUp() {
|
public void tearDown(EntityManagerFactoryScope scope) {
|
||||||
final EntityManager entityManager = getOrCreateEntityManager();
|
scope.inTransaction(
|
||||||
try {
|
entityManager -> {
|
||||||
entityManager.getTransaction().begin();
|
entityManager.createNativeQuery( "DROP ALIAS IF EXISTS get_all_entities" ).executeUpdate();
|
||||||
entityManager.createNativeQuery( "CREATE ALIAS get_all_entities FOR \"" + H2StoreProcedureTest.class.getCanonicalName() + ".getAllEntities\";" )
|
entityManager.createNativeQuery( "DROP ALIAS IF EXISTS by_id" ).executeUpdate();
|
||||||
.executeUpdate();
|
}
|
||||||
|
);
|
||||||
entityManager.createNativeQuery( "CREATE ALIAS by_id FOR \"" + H2StoreProcedureTest.class.getCanonicalName() + ".entityById\";" )
|
|
||||||
.executeUpdate();
|
|
||||||
MyEntity entity = new MyEntity();
|
|
||||||
entity.id = 1;
|
|
||||||
entity.name = "entity1";
|
|
||||||
entityManager.persist( entity );
|
|
||||||
|
|
||||||
entityManager.getTransaction().commit();
|
|
||||||
|
|
||||||
}
|
|
||||||
catch (Exception e) {
|
|
||||||
if ( entityManager.getTransaction().isActive() ) {
|
|
||||||
entityManager.getTransaction().rollback();
|
|
||||||
}
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
entityManager.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@After
|
|
||||||
public void tearDown() {
|
|
||||||
final EntityManager entityManager = getOrCreateEntityManager();
|
|
||||||
try {
|
|
||||||
entityManager.getTransaction().begin();
|
|
||||||
entityManager.createNativeQuery( "DROP ALIAS IF EXISTS get_all_entities" ).executeUpdate();
|
|
||||||
entityManager.createNativeQuery( "DROP ALIAS IF EXISTS by_id" ).executeUpdate();
|
|
||||||
entityManager.getTransaction().commit();
|
|
||||||
}
|
|
||||||
catch (Exception e) {
|
|
||||||
if ( entityManager.getTransaction().isActive() ) {
|
|
||||||
entityManager.getTransaction().rollback();
|
|
||||||
}
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
entityManager.close();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ResultSet getAllEntities(Connection conn) throws SQLException {
|
public static ResultSet getAllEntities(Connection conn) throws SQLException {
|
||||||
|
@ -102,50 +77,49 @@ public class H2StoreProcedureTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testStoreProcedureGetParameters() {
|
public void testStoreProcedureGetParameters(EntityManagerFactoryScope scope) {
|
||||||
final EntityManager entityManager = getOrCreateEntityManager();
|
scope.inTransaction(
|
||||||
try {
|
entityManager -> {
|
||||||
StoredProcedureQuery query = entityManager.createStoredProcedureQuery( "get_all_entities", MyEntity.class );
|
StoredProcedureQuery query = entityManager.createStoredProcedureQuery(
|
||||||
final Set<Parameter<?>> parameters = query.getParameters();
|
"get_all_entities",
|
||||||
assertThat( parameters.size(), is( 0 ) );
|
MyEntity.class
|
||||||
|
);
|
||||||
|
final Set<Parameter<?>> parameters = query.getParameters();
|
||||||
|
assertThat( parameters.size(), is( 0 ) );
|
||||||
|
|
||||||
final List resultList = query.getResultList();
|
final List resultList = query.getResultList();
|
||||||
assertThat( resultList.size(), is( 1 ) );
|
assertThat( resultList.size(), is( 1 ) );
|
||||||
}
|
}
|
||||||
finally {
|
);
|
||||||
entityManager.close();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testStoreProcedureGetParameterByPosition() {
|
public void testStoreProcedureGetParameterByPosition(EntityManagerFactoryScope scope) {
|
||||||
final EntityManager entityManager = getOrCreateEntityManager();
|
scope.inTransaction(
|
||||||
try {
|
entityManager -> {
|
||||||
StoredProcedureQuery query = entityManager.createStoredProcedureQuery( "by_Id", MyEntity.class );
|
StoredProcedureQuery query = entityManager.createStoredProcedureQuery( "by_Id", MyEntity.class );
|
||||||
query.registerStoredProcedureParameter( 1, Long.class, ParameterMode.IN );
|
query.registerStoredProcedureParameter( 1, Long.class, ParameterMode.IN );
|
||||||
|
|
||||||
query.setParameter( 1, 1L );
|
query.setParameter( 1, 1L );
|
||||||
|
|
||||||
final List resultList = query.getResultList();
|
final List resultList = query.getResultList();
|
||||||
assertThat( resultList.size(), is( 1 ) );
|
assertThat( resultList.size(), is( 1 ) );
|
||||||
|
|
||||||
final Set<Parameter<?>> parameters = query.getParameters();
|
final Set<Parameter<?>> parameters = query.getParameters();
|
||||||
assertThat( parameters.size(), is( 1 ) );
|
assertThat( parameters.size(), is( 1 ) );
|
||||||
|
|
||||||
final Parameter<?> parameter = query.getParameter( 1 );
|
final Parameter<?> parameter = query.getParameter( 1 );
|
||||||
assertThat( parameter, not( nullValue() ) );
|
assertThat( parameter, not( nullValue() ) );
|
||||||
|
|
||||||
try {
|
try {
|
||||||
query.getParameter( 2 );
|
query.getParameter( 2 );
|
||||||
fail( "IllegalArgumentException expected, parameter at position 2 does not exist" );
|
fail( "IllegalArgumentException expected, parameter at position 2 does not exist" );
|
||||||
}
|
}
|
||||||
catch (IllegalArgumentException iae) {
|
catch (IllegalArgumentException iae) {
|
||||||
//expected
|
//expected
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
finally {
|
);
|
||||||
entityManager.close();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Entity(name = "MyEntity")
|
@Entity(name = "MyEntity")
|
||||||
|
|
|
@ -9,7 +9,9 @@ import org.hibernate.annotations.BatchSize;
|
||||||
import org.hibernate.annotations.Fetch;
|
import org.hibernate.annotations.Fetch;
|
||||||
import org.hibernate.annotations.FetchMode;
|
import org.hibernate.annotations.FetchMode;
|
||||||
import org.hibernate.cfg.AvailableSettings;
|
import org.hibernate.cfg.AvailableSettings;
|
||||||
|
import org.hibernate.dialect.DatabaseVersion;
|
||||||
import org.hibernate.dialect.H2Dialect;
|
import org.hibernate.dialect.H2Dialect;
|
||||||
|
import org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo;
|
||||||
|
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
import org.hibernate.testing.orm.junit.DomainModel;
|
import org.hibernate.testing.orm.junit.DomainModel;
|
||||||
|
@ -56,7 +58,19 @@ public class MultiLoadSubSelectCollectionDialectWithLimitTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class TestDialect extends H2Dialect{
|
public static class TestDialect extends H2Dialect {
|
||||||
|
|
||||||
|
public TestDialect(DialectResolutionInfo info) {
|
||||||
|
super( info );
|
||||||
|
}
|
||||||
|
|
||||||
|
public TestDialect() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public TestDialect(DatabaseVersion version) {
|
||||||
|
super( version );
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getInExpressionCountLimit() {
|
public int getInExpressionCountLimit() {
|
||||||
return 50;
|
return 50;
|
||||||
|
|
|
@ -19,7 +19,9 @@ import jakarta.persistence.criteria.Root;
|
||||||
import org.hibernate.annotations.Formula;
|
import org.hibernate.annotations.Formula;
|
||||||
import org.hibernate.cfg.Configuration;
|
import org.hibernate.cfg.Configuration;
|
||||||
import org.hibernate.cfg.Environment;
|
import org.hibernate.cfg.Environment;
|
||||||
|
import org.hibernate.dialect.DatabaseVersion;
|
||||||
import org.hibernate.dialect.H2Dialect;
|
import org.hibernate.dialect.H2Dialect;
|
||||||
|
import org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo;
|
||||||
|
|
||||||
import org.hibernate.testing.RequiresDialect;
|
import org.hibernate.testing.RequiresDialect;
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
|
@ -200,6 +202,19 @@ public class FormulaWithColumnTypesTest extends BaseCoreFunctionalTestCase {
|
||||||
|
|
||||||
public ExtendedDialect() {
|
public ExtendedDialect() {
|
||||||
super();
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ExtendedDialect(DatabaseVersion version) {
|
||||||
|
super( version );
|
||||||
|
}
|
||||||
|
|
||||||
|
public ExtendedDialect(DialectResolutionInfo info) {
|
||||||
|
super( info );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void registerDefaultKeywords() {
|
||||||
|
super.registerDefaultKeywords();
|
||||||
registerKeyword( "FLOAT" );
|
registerKeyword( "FLOAT" );
|
||||||
registerKeyword( "INTEGER" );
|
registerKeyword( "INTEGER" );
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ import org.hibernate.testing.orm.junit.DomainModel;
|
||||||
import org.hibernate.testing.orm.junit.RequiresDialect;
|
import org.hibernate.testing.orm.junit.RequiresDialect;
|
||||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||||
import org.hibernate.testing.orm.junit.SessionFactoryScope;
|
import org.hibernate.testing.orm.junit.SessionFactoryScope;
|
||||||
|
import org.hibernate.testing.orm.junit.SkipForDialect;
|
||||||
import org.junit.jupiter.api.AfterEach;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
@ -41,6 +42,7 @@ import org.assertj.core.util.Arrays;
|
||||||
@DomainModel(annotatedClasses = Post.class)
|
@DomainModel(annotatedClasses = Post.class)
|
||||||
@SessionFactory
|
@SessionFactory
|
||||||
@RequiresDialect(H2Dialect.class)
|
@RequiresDialect(H2Dialect.class)
|
||||||
|
@SkipForDialect(dialectClass = H2Dialect.class, majorVersion = 2, reason = "Array support was changed to now be typed")
|
||||||
public class StringArrayContributorTests {
|
public class StringArrayContributorTests {
|
||||||
@Test
|
@Test
|
||||||
public void simpleTest(SessionFactoryScope scope) {
|
public void simpleTest(SessionFactoryScope scope) {
|
||||||
|
|
|
@ -35,6 +35,7 @@ import org.hibernate.testing.TestForIssue;
|
||||||
import org.hibernate.testing.orm.junit.EntityManagerFactoryScope;
|
import org.hibernate.testing.orm.junit.EntityManagerFactoryScope;
|
||||||
import org.hibernate.testing.orm.junit.Jpa;
|
import org.hibernate.testing.orm.junit.Jpa;
|
||||||
import org.hibernate.testing.orm.junit.RequiresDialect;
|
import org.hibernate.testing.orm.junit.RequiresDialect;
|
||||||
|
import org.hibernate.testing.orm.junit.SkipForDialect;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -42,6 +43,7 @@ import org.junit.jupiter.api.Test;
|
||||||
*/
|
*/
|
||||||
@TestForIssue( jiraKey = "HHH-12292")
|
@TestForIssue( jiraKey = "HHH-12292")
|
||||||
@RequiresDialect(H2Dialect.class)
|
@RequiresDialect(H2Dialect.class)
|
||||||
|
@SkipForDialect(dialectClass = H2Dialect.class, majorVersion = 2, reason = "Array support was changed to now be typed")
|
||||||
@Jpa(
|
@Jpa(
|
||||||
annotatedClasses = QueryParametersValidationArrayTest.Event.class
|
annotatedClasses = QueryParametersValidationArrayTest.Event.class
|
||||||
)
|
)
|
||||||
|
|
|
@ -17,6 +17,8 @@ import org.hibernate.boot.registry.StandardServiceRegistry;
|
||||||
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
||||||
import org.hibernate.boot.spi.MetadataImplementor;
|
import org.hibernate.boot.spi.MetadataImplementor;
|
||||||
import org.hibernate.cfg.Environment;
|
import org.hibernate.cfg.Environment;
|
||||||
|
import org.hibernate.dialect.Dialect;
|
||||||
|
import org.hibernate.dialect.H2Dialect;
|
||||||
import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
|
import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
|
||||||
import org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator;
|
import org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator;
|
||||||
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
||||||
|
@ -30,6 +32,7 @@ import org.hibernate.tool.schema.internal.exec.JdbcContext;
|
||||||
import org.hibernate.tool.schema.spi.SchemaManagementTool;
|
import org.hibernate.tool.schema.spi.SchemaManagementTool;
|
||||||
|
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
|
import org.junit.Assume;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
|
@ -88,6 +91,9 @@ public class TestExtraPhysicalTableTypes {
|
||||||
@Test
|
@Test
|
||||||
public void testExtraPhysicalTableTypesPropertyEmptyStringValue() throws Exception {
|
public void testExtraPhysicalTableTypesPropertyEmptyStringValue() throws Exception {
|
||||||
buildMetadata( " " );
|
buildMetadata( " " );
|
||||||
|
Dialect dialect = metadata.getDatabase().getDialect();
|
||||||
|
// As of 2.0.202 H2 reports tables as BASE TABLE so we add the type through the dialect
|
||||||
|
Assume.assumeFalse( dialect instanceof H2Dialect && dialect.getVersion().isSameOrAfter( 2 ) );
|
||||||
DdlTransactionIsolator ddlTransactionIsolator = buildDdlTransactionIsolator();
|
DdlTransactionIsolator ddlTransactionIsolator = buildDdlTransactionIsolator();
|
||||||
try {
|
try {
|
||||||
InformationExtractorJdbcDatabaseMetaDataImplTest informationExtractor = buildInformationExtractorJdbcDatabaseMetaDataImplTest(
|
InformationExtractorJdbcDatabaseMetaDataImplTest informationExtractor = buildInformationExtractorJdbcDatabaseMetaDataImplTest(
|
||||||
|
@ -102,8 +108,11 @@ public class TestExtraPhysicalTableTypes {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNoExtraPhysicalTabeTypesProperty() throws Exception {
|
public void testNoExtraPhysicalTableTypesProperty() throws Exception {
|
||||||
buildMetadata( null );
|
buildMetadata( null );
|
||||||
|
Dialect dialect = metadata.getDatabase().getDialect();
|
||||||
|
// As of 2.0.202 H2 reports tables as BASE TABLE so we add the type through the dialect
|
||||||
|
Assume.assumeFalse( dialect instanceof H2Dialect && dialect.getVersion().isSameOrAfter( 2 ) );
|
||||||
DdlTransactionIsolator ddlTransactionIsolator = buildDdlTransactionIsolator();
|
DdlTransactionIsolator ddlTransactionIsolator = buildDdlTransactionIsolator();
|
||||||
try {
|
try {
|
||||||
InformationExtractorJdbcDatabaseMetaDataImplTest informationExtractor = buildInformationExtractorJdbcDatabaseMetaDataImplTest(
|
InformationExtractorJdbcDatabaseMetaDataImplTest informationExtractor = buildInformationExtractorJdbcDatabaseMetaDataImplTest(
|
||||||
|
|
|
@ -245,7 +245,19 @@ public class IndividuallySchemaValidatorImplTest extends BaseUnitTestCase {
|
||||||
Assert.fail( "SchemaManagementException expected" );
|
Assert.fail( "SchemaManagementException expected" );
|
||||||
}
|
}
|
||||||
catch (SchemaManagementException e) {
|
catch (SchemaManagementException e) {
|
||||||
assertEquals("Schema-validation: wrong column type encountered in column [name] in table [SomeSchema.ColumnEntity]; found [varchar (Types#VARCHAR)], but expecting [integer (Types#INTEGER)]", e.getMessage());
|
if ( metadata.getDatabase().getDialect().getVersion().isSameOrAfter( 2 ) ) {
|
||||||
|
// Reports "character varying" since 2.0
|
||||||
|
assertEquals(
|
||||||
|
"Schema-validation: wrong column type encountered in column [name] in table [SomeSchema.ColumnEntity]; found [character (Types#VARCHAR)], but expecting [integer (Types#INTEGER)]",
|
||||||
|
e.getMessage()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
assertEquals(
|
||||||
|
"Schema-validation: wrong column type encountered in column [name] in table [SomeSchema.ColumnEntity]; found [varchar (Types#VARCHAR)], but expecting [integer (Types#INTEGER)]",
|
||||||
|
e.getMessage()
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
|
|
|
@ -25,6 +25,7 @@ import jakarta.persistence.Entity;
|
||||||
import jakarta.persistence.Id;
|
import jakarta.persistence.Id;
|
||||||
|
|
||||||
import org.hibernate.dialect.AbstractHANADialect;
|
import org.hibernate.dialect.AbstractHANADialect;
|
||||||
|
import org.hibernate.dialect.H2Dialect;
|
||||||
import org.hibernate.dialect.HSQLDialect;
|
import org.hibernate.dialect.HSQLDialect;
|
||||||
import org.hibernate.dialect.MariaDBDialect;
|
import org.hibernate.dialect.MariaDBDialect;
|
||||||
import org.hibernate.dialect.MySQLDialect;
|
import org.hibernate.dialect.MySQLDialect;
|
||||||
|
@ -234,6 +235,7 @@ public class OffsetTimeTest extends AbstractJavaTimeTypeTest<OffsetTime, OffsetT
|
||||||
+ " Since java.sql.Time holds the whole timestamp, not just the time,"
|
+ " Since java.sql.Time holds the whole timestamp, not just the time,"
|
||||||
+ " its equals() method ends up returning false in this test.")
|
+ " its equals() method ends up returning false in this test.")
|
||||||
@SkipForDialect(value = HSQLDialect.class, comment = "Timezone issue?")
|
@SkipForDialect(value = HSQLDialect.class, comment = "Timezone issue?")
|
||||||
|
@SkipForDialect(value = H2Dialect.class, comment = "As of version 2.0.202 this seems to be a problem")
|
||||||
public void writeThenNativeRead() {
|
public void writeThenNativeRead() {
|
||||||
super.writeThenNativeRead();
|
super.writeThenNativeRead();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue