HHH-13917: Add support for HANA Cloud

This commit is contained in:
Jonathan Bregler 2020-03-27 17:08:28 +01:00 committed by Sanne Grinovero
parent 4741fa4f33
commit 95c9526dda
12 changed files with 236 additions and 55 deletions

View File

@ -236,10 +236,10 @@ public class SubselectTest extends BaseEntityManagerFunctionalTestCase {
"select " +
" a.id as id, " +
" concat(concat(c.first_name, ' '), c.last_name) as clientName, " +
" sum(at.cents) as balance " +
" sum(atr.cents) as balance " +
"from account a " +
"join client c on c.id = a.client_id " +
"join account_transaction at on a.id = at.account_id " +
"join account_transaction atr on a.id = atr.account_id " +
"group by a.id, concat(concat(c.first_name, ' '), c.last_name)"
)
@Synchronize( {"client", "account", "account_transaction"} )

View File

@ -107,6 +107,13 @@ ext {
'jdbc.pass' : 'H1bernate_test',
'jdbc.url' : 'jdbc:sap://localhost:30015/'
],
hana_cloud : [
'db.dialect' : 'org.hibernate.dialect.HANACloudColumnStoreDialect',
'jdbc.driver': 'com.sap.db.jdbc.Driver',
'jdbc.user' : 'HIBERNATE_TEST',
'jdbc.pass' : 'H1bernate_test',
'jdbc.url' : 'jdbc:sap://localhost:443/?encrypt=true&validateCertificate=false'
],
hana_vlad : [
'db.dialect' : 'org.hibernate.dialect.HANAColumnStoreDialect',
'jdbc.driver': 'com.sap.db.jdbc.Driver',

View File

@ -709,18 +709,17 @@ public abstract class AbstractHANADialect extends Dialect {
private static final int MAX_LOB_PREFETCH_SIZE_DEFAULT_VALUE = 1024;
private static final Boolean USE_LEGACY_BOOLEAN_TYPE_DEFAULT_VALUE = Boolean.FALSE;
private static final Boolean USE_UNICODE_STRING_TYPES_DEFAULT_VALUE = Boolean.FALSE;
private static final Boolean TREAT_DOUBLE_TYPED_FIELDS_AS_DECIMAL_DEFAULT_VALUE = Boolean.FALSE;
private HANANClobTypeDescriptor nClobTypeDescriptor = new HANANClobTypeDescriptor( MAX_LOB_PREFETCH_SIZE_DEFAULT_VALUE );
private HANABlobTypeDescriptor blobTypeDescriptor = new HANABlobTypeDescriptor( MAX_LOB_PREFETCH_SIZE_DEFAULT_VALUE );
private HANAClobTypeDescriptor clobTypeDescriptor = new HANAClobTypeDescriptor( MAX_LOB_PREFETCH_SIZE_DEFAULT_VALUE,
USE_UNICODE_STRING_TYPES_DEFAULT_VALUE.booleanValue() );
private HANAClobTypeDescriptor clobTypeDescriptor;
private boolean useLegacyBooleanType = USE_LEGACY_BOOLEAN_TYPE_DEFAULT_VALUE.booleanValue();
private boolean useUnicodeStringTypes = USE_UNICODE_STRING_TYPES_DEFAULT_VALUE.booleanValue();
private boolean useUnicodeStringTypes;
private boolean treatDoubleTypedFieldsAsDecimal = TREAT_DOUBLE_TYPED_FIELDS_AS_DECIMAL_DEFAULT_VALUE.booleanValue();
/*
@ -766,6 +765,10 @@ public abstract class AbstractHANADialect extends Dialect {
public AbstractHANADialect() {
super();
this.useUnicodeStringTypes = useUnicodeStringTypesDefault().booleanValue();
this.clobTypeDescriptor = new HANAClobTypeDescriptor( MAX_LOB_PREFETCH_SIZE_DEFAULT_VALUE,
useUnicodeStringTypesDefault().booleanValue() );
registerColumnType( Types.DECIMAL, "decimal($p, $s)" );
registerColumnType( Types.NUMERIC, "decimal($p, $s)" );
registerColumnType( Types.DOUBLE, "double" );
@ -804,7 +807,7 @@ public abstract class AbstractHANADialect extends Dialect {
registerHibernateType( Types.NCLOB, StandardBasicTypes.MATERIALIZED_NCLOB.getName() );
registerHibernateType( Types.CLOB, StandardBasicTypes.MATERIALIZED_CLOB.getName() );
registerHibernateType( Types.BLOB, StandardBasicTypes.MATERIALIZED_BLOB.getName() );
registerHibernateType( Types.NVARCHAR, StandardBasicTypes.STRING.getName() );
registerHibernateType( Types.NVARCHAR, StandardBasicTypes.NSTRING.getName() );
registerFunction( "to_date", new StandardSQLFunction( "to_date", StandardBasicTypes.DATE ) );
registerFunction( "to_seconddate", new StandardSQLFunction( "to_seconddate", StandardBasicTypes.TIMESTAMP ) );
@ -1143,9 +1146,9 @@ public abstract class AbstractHANADialect extends Dialect {
case Types.BOOLEAN:
return this.useLegacyBooleanType ? BitTypeDescriptor.INSTANCE : BooleanTypeDescriptor.INSTANCE;
case Types.VARCHAR:
return this.useUnicodeStringTypes ? NVarcharTypeDescriptor.INSTANCE : VarcharTypeDescriptor.INSTANCE;
return this.isUseUnicodeStringTypes() ? NVarcharTypeDescriptor.INSTANCE : VarcharTypeDescriptor.INSTANCE;
case Types.CHAR:
return this.useUnicodeStringTypes ? NCharTypeDescriptor.INSTANCE : CharTypeDescriptor.INSTANCE;
return this.isUseUnicodeStringTypes() ? NCharTypeDescriptor.INSTANCE : CharTypeDescriptor.INSTANCE;
case Types.DOUBLE:
return this.treatDoubleTypedFieldsAsDecimal ? DecimalTypeDescriptor.INSTANCE : DoubleTypeDescriptor.INSTANCE;
default:
@ -1572,23 +1575,25 @@ public abstract class AbstractHANADialect extends Dialect {
this.blobTypeDescriptor = new HANABlobTypeDescriptor( maxLobPrefetchSize );
}
this.useUnicodeStringTypes = configurationService.getSetting( USE_UNICODE_STRING_TYPES_PARAMETER_NAME, StandardConverters.BOOLEAN,
USE_UNICODE_STRING_TYPES_DEFAULT_VALUE ).booleanValue();
if ( supportsAsciiStringTypes() ) {
this.useUnicodeStringTypes = configurationService.getSetting( USE_UNICODE_STRING_TYPES_PARAMETER_NAME, StandardConverters.BOOLEAN,
useUnicodeStringTypesDefault() ).booleanValue();
if ( this.useUnicodeStringTypes ) {
registerColumnType( Types.CHAR, "nvarchar(1)" );
registerColumnType( Types.VARCHAR, 5000, "nvarchar($l)" );
registerColumnType( Types.LONGVARCHAR, 5000, "nvarchar($l)" );
if ( this.isUseUnicodeStringTypes() ) {
registerColumnType( Types.CHAR, "nvarchar(1)" );
registerColumnType( Types.VARCHAR, 5000, "nvarchar($l)" );
registerColumnType( Types.LONGVARCHAR, 5000, "nvarchar($l)" );
// for longer values map to clob/nclob
registerColumnType( Types.LONGVARCHAR, "nclob" );
registerColumnType( Types.VARCHAR, "nclob" );
registerColumnType( Types.CLOB, "nclob" );
}
// for longer values map to clob/nclob
registerColumnType( Types.LONGVARCHAR, "nclob" );
registerColumnType( Types.VARCHAR, "nclob" );
registerColumnType( Types.CLOB, "nclob" );
}
if ( this.clobTypeDescriptor.getMaxLobPrefetchSize() != maxLobPrefetchSize
|| this.clobTypeDescriptor.isUseUnicodeStringTypes() != this.useUnicodeStringTypes ) {
this.clobTypeDescriptor = new HANAClobTypeDescriptor( maxLobPrefetchSize, this.useUnicodeStringTypes );
if ( this.clobTypeDescriptor.getMaxLobPrefetchSize() != maxLobPrefetchSize
|| this.clobTypeDescriptor.isUseUnicodeStringTypes() != this.isUseUnicodeStringTypes() ) {
this.clobTypeDescriptor = new HANAClobTypeDescriptor( maxLobPrefetchSize, this.isUseUnicodeStringTypes() );
}
}
this.useLegacyBooleanType = configurationService.getSetting( USE_LEGACY_BOOLEAN_TYPE_PARAMETER_NAME, StandardConverters.BOOLEAN,
@ -1660,7 +1665,16 @@ public abstract class AbstractHANADialect extends Dialect {
return false;
}
@Override
public boolean supportsNoColumnsInsert() {
return false;
}
public boolean isUseUnicodeStringTypes() {
return this.useUnicodeStringTypes;
}
protected abstract boolean supportsAsciiStringTypes();
protected abstract Boolean useUnicodeStringTypesDefault();
}

View File

@ -66,7 +66,6 @@ public enum Database {
}
}
if ( databaseName.startsWith( "DB2/" ) ) {
return new DB2Dialect();
}
@ -176,9 +175,13 @@ public enum Database {
@Override
public Dialect resolveDialect(DialectResolutionInfo info) {
final String databaseName = info.getDatabaseName();
int databaseMajorVersion = info.getDatabaseMajorVersion();
if ( "HDB".equals( databaseName ) ) {
// SAP recommends defaulting to column store.
if ( databaseMajorVersion >= 4 ) {
return new HANACloudColumnStoreDialect();
}
return latestDialectInstance( this );
}
@ -358,7 +361,7 @@ public enum Database {
return new MySQL57Dialect();
}
}
else if ( majorVersion < 8) {
else if ( majorVersion < 8 ) {
// There is no MySQL 6 or 7.
// Adding this just in case.
return new MySQL57Dialect();

View File

@ -0,0 +1,123 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.dialect;
import java.sql.Types;
import org.hibernate.dialect.function.SQLFunctionTemplate;
import org.hibernate.dialect.function.StandardSQLFunction;
import org.hibernate.dialect.function.VarArgsSQLFunction;
import org.hibernate.hql.spi.id.IdTableSupportStandardImpl;
import org.hibernate.hql.spi.id.MultiTableBulkIdStrategy;
import org.hibernate.hql.spi.id.global.GlobalTemporaryTableBulkIdStrategy;
import org.hibernate.hql.spi.id.local.AfterUseAction;
import org.hibernate.type.StandardBasicTypes;
/**
* An SQL dialect for the SAP HANA Cloud column store.
* <p>
* For more information on interacting with the SAP HANA Cloud database, refer to the
* <a href="https://help.sap.com/viewer/c1d3f60099654ecfb3fe36ac93c121bb/cloud/">SAP HANA Cloud SQL Reference Guide</a>
* and the <a href=
* "https://help.sap.com/viewer/0eec0d68141541d1b07893a39944924e/latest/en-US/434e2962074540e18c802fd478de86d6.html">SAP
* HANA Client Interface Programming Reference</a>.
* <p>
* Column tables are created by this dialect when using the auto-ddl feature.
*
* @author <a href="mailto:jonathan.bregler@sap.com">Jonathan Bregler</a>
*/
public class HANACloudColumnStoreDialect extends AbstractHANADialect {
public HANACloudColumnStoreDialect() {
super();
registerColumnType( Types.CHAR, "nvarchar(1)" );
registerColumnType( Types.VARCHAR, 5000, "nvarchar($l)" );
registerColumnType( Types.LONGVARCHAR, 5000, "nvarchar($l)" );
// for longer values map to clob/nclob
registerColumnType( Types.LONGVARCHAR, "nclob" );
registerColumnType( Types.VARCHAR, "nclob" );
registerColumnType( Types.CLOB, "nclob" );
registerHibernateType( Types.CLOB, StandardBasicTypes.MATERIALIZED_NCLOB.getName() );
registerHibernateType( Types.NCHAR, StandardBasicTypes.NSTRING.getName() );
registerHibernateType( Types.CHAR, StandardBasicTypes.CHARACTER.getName() );
registerHibernateType( Types.CHAR, 1, StandardBasicTypes.CHARACTER.getName() );
registerHibernateType( Types.CHAR, 5000, StandardBasicTypes.NSTRING.getName() );
registerHibernateType( Types.VARCHAR, StandardBasicTypes.NSTRING.getName() );
registerHibernateType( Types.LONGVARCHAR, StandardBasicTypes.NTEXT.getName() );
// register additional keywords
registerHanaCloudKeywords();
// full-text search functions
registerFunction( "score", new StandardSQLFunction( "score", StandardBasicTypes.DOUBLE ) );
registerFunction( "contains", new VarArgsSQLFunction( StandardBasicTypes.BOOLEAN, "contains(", ",", ") /*" ) );
registerFunction( "contains_rhs", new SQLFunctionTemplate( StandardBasicTypes.BOOLEAN, "*/" ) );
registerFunction( "not_contains", new VarArgsSQLFunction( StandardBasicTypes.BOOLEAN, "not contains(", ",", ") /*" ) );
}
private void registerHanaCloudKeywords() {
registerKeyword( "array" );
registerKeyword( "at" );
registerKeyword( "authorization" );
registerKeyword( "between" );
registerKeyword( "by" );
registerKeyword( "collate" );
registerKeyword( "empty" );
registerKeyword( "filter" );
registerKeyword( "grouping" );
registerKeyword( "no" );
registerKeyword( "not" );
registerKeyword( "of" );
registerKeyword( "over" );
registerKeyword( "recursive" );
registerKeyword( "row" );
registerKeyword( "table" );
registerKeyword( "to" );
registerKeyword( "window" );
registerKeyword( "within" );
}
@Override
public String getCreateTableString() {
return "create column table";
}
@Override
public MultiTableBulkIdStrategy getDefaultMultiTableBulkIdStrategy() {
return new GlobalTemporaryTableBulkIdStrategy( new IdTableSupportStandardImpl() {
@Override
public String getCreateIdTableCommand() {
return "create global temporary column table";
}
@Override
public String getTruncateIdTableCommand() {
return "truncate table";
}
}, AfterUseAction.CLEAN );
}
@Override
protected boolean supportsAsciiStringTypes() {
return false;
}
@Override
protected Boolean useUnicodeStringTypesDefault() {
return Boolean.TRUE;
}
@Override
public boolean isUseUnicodeStringTypes() {
return true;
}
}

View File

@ -30,7 +30,7 @@ import org.hibernate.type.StandardBasicTypes;
* @author <a href="mailto:jonathan.bregler@sap.com">Jonathan Bregler</a>
*/
public class HANAColumnStoreDialect extends AbstractHANADialect {
public HANAColumnStoreDialect() {
super();
@ -64,4 +64,14 @@ public class HANAColumnStoreDialect extends AbstractHANADialect {
}, AfterUseAction.CLEAN );
}
@Override
protected boolean supportsAsciiStringTypes() {
return true;
}
@Override
protected Boolean useUnicodeStringTypesDefault() {
return Boolean.FALSE;
}
}

View File

@ -46,4 +46,14 @@ public class HANARowStoreDialect extends AbstractHANADialect {
}
}, AfterUseAction.CLEAN );
}
@Override
protected boolean supportsAsciiStringTypes() {
return true;
}
@Override
protected Boolean useUnicodeStringTypesDefault() {
return Boolean.FALSE;
}
}

View File

@ -29,6 +29,7 @@ import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.boot.spi.MetadataImplementor;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.cfg.Configuration;
import org.hibernate.dialect.HANACloudColumnStoreDialect;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.hql.internal.ast.tree.JavaConstantNode;
import org.hibernate.internal.util.ConfigHelper;
@ -332,7 +333,12 @@ public class AttributeConverterTest extends BaseUnitTestCase {
}
AbstractStandardBasicType basicType = assertTyping( AbstractStandardBasicType.class, type );
assertTyping( EnumJavaTypeDescriptor.class, basicType.getJavaTypeDescriptor() );
assertEquals( Types.VARCHAR, basicType.getSqlTypeDescriptor().getSqlType() );
if (metadata.getDatabase().getDialect() instanceof HANACloudColumnStoreDialect) {
assertEquals( Types.NVARCHAR, basicType.getSqlTypeDescriptor().getSqlType() );
}
else {
assertEquals( Types.VARCHAR, basicType.getSqlTypeDescriptor().getSqlType() );
}
// then lets build the SF and verify its use...
final SessionFactory sf = metadata.buildSessionFactory();

View File

@ -14,10 +14,11 @@ import java.sql.PreparedStatement;
import javax.persistence.Entity;
import javax.persistence.Id;
import org.hibernate.Session;
import org.hibernate.dialect.HANACloudColumnStoreDialect;
import org.hibernate.dialect.HANAColumnStoreDialect;
import org.hibernate.query.Query;
import org.hibernate.testing.RequiresDialect;
import org.hibernate.testing.SkipForDialect;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.junit.Test;
@ -28,6 +29,7 @@ import org.junit.Test;
* @author Jonathan Bregler
*/
@RequiresDialect(value = { HANAColumnStoreDialect.class })
@SkipForDialect(value = HANACloudColumnStoreDialect.class)
public class HANASearchTest extends BaseCoreFunctionalTestCase {
private static final String ENTITY_NAME = "SearchEntity";
@ -136,7 +138,7 @@ public class HANASearchTest extends BaseCoreFunctionalTestCase {
entity.c = "TEST STRING";
s.persist( entity );
s.getTransaction().commit();
s.beginTransaction();
@ -171,7 +173,7 @@ public class HANASearchTest extends BaseCoreFunctionalTestCase {
s.persist( entity );
s.flush();
s.getTransaction().commit();
s.beginTransaction();
@ -208,7 +210,7 @@ public class HANASearchTest extends BaseCoreFunctionalTestCase {
s.persist( entity );
s.flush();
s.getTransaction().commit();
s.beginTransaction();

View File

@ -24,8 +24,8 @@ import static org.junit.Assert.fail;
public class HANANoColumnInsertTest extends BaseCoreFunctionalTestCase {
public String[] getMappings() {
return new String[] {
"ops/Competition.hbm.xml"
return new String[]{
"ops/Competition.hbm.xml"
};
}
@ -34,10 +34,12 @@ public class HANANoColumnInsertTest extends BaseCoreFunctionalTestCase {
try {
super.buildSessionFactory();
fail("Should have thrown MappingException!");
fail( "Should have thrown MappingException!" );
}
catch (MappingException e) {
assertEquals("The INSERT statement for table [Competition] contains no column, and this is not supported by [org.hibernate.dialect.HANAColumnStoreDialect]", e.getMessage());
assertEquals(
"The INSERT statement for table [Competition] contains no column, and this is not supported by [" + getDialect().getClass().getName() + "]",
e.getMessage() );
}
}
@ -45,4 +47,3 @@ public class HANANoColumnInsertTest extends BaseCoreFunctionalTestCase {
public void test() throws Exception {
}
}

View File

@ -89,7 +89,7 @@ public class QueryHintHANATest extends BaseNonConfigCoreFunctionalTestCase {
doInHibernate( this::sessionFactory, s -> {
Query<Employee> query = s.createQuery( "FROM QueryHintHANATest$Employee e WHERE e.department.name = :departmentName", Employee.class )
.addQueryHint( "NO_CS_JOIN" )
.addQueryHint( "OPTIMIZE_METAMODEL" )
.addQueryHint( "IGNORE_PLAN_CACHE" )
.setParameter( "departmentName", "Sales" );
List<Employee> results = query.list();
@ -98,7 +98,7 @@ public class QueryHintHANATest extends BaseNonConfigCoreFunctionalTestCase {
sqlStatementInterceptor.assertExecutedCount( 1 );
assertThat( sqlStatementInterceptor.getSqlQueries().get( 0 ), containsString( " with hint (NO_CS_JOIN,OPTIMIZE_METAMODEL)" ) );
assertThat( sqlStatementInterceptor.getSqlQueries().get( 0 ), containsString( " with hint (NO_CS_JOIN,IGNORE_PLAN_CACHE)" ) );
sqlStatementInterceptor.clear();
// ensure the insertion logic can handle a comment appended to the front

View File

@ -44,6 +44,8 @@ import static org.junit.Assert.fail;
public class HANASchemaMigrationTargetScriptCreationTest extends BaseCoreFunctionalTestCase {
private File output;
private String varcharType;
private String clobType;
@Override
protected Class<?>[] getAnnotatedClasses() {
@ -58,14 +60,16 @@ public class HANASchemaMigrationTargetScriptCreationTest extends BaseCoreFunctio
@Override
protected void configure(Configuration configuration) {
try {
output = File.createTempFile( "update_script", ".sql" );
this.output = File.createTempFile( "update_script", ".sql" );
}
catch (IOException e) {
fail( e.getMessage() );
}
output.deleteOnExit();
this.output.deleteOnExit();
configuration.setProperty( Environment.HBM2DDL_SCRIPTS_ACTION, "create" );
configuration.setProperty( Environment.HBM2DDL_SCRIPTS_CREATE_TARGET, output.getAbsolutePath() );
configuration.setProperty( Environment.HBM2DDL_SCRIPTS_CREATE_TARGET, this.output.getAbsolutePath() );
this.varcharType = ( (AbstractHANADialect) getDialect() ).isUseUnicodeStringTypes() ? "nvarchar" : "varchar";
this.clobType = ( (AbstractHANADialect) getDialect() ).isUseUnicodeStringTypes() ? "nclob" : "clob";
}
@After
@ -88,8 +92,9 @@ public class HANASchemaMigrationTargetScriptCreationTest extends BaseCoreFunctio
@TestForIssue(jiraKey = "HHH-12302")
public void testTargetScriptIsCreatedStringTypeDefault() throws Exception {
this.rebuildSessionFactory();
String fileContent = new String( Files.readAllBytes( output.toPath() ) );
Pattern fileContentPattern = Pattern.compile( "create( (column|row))? table test_entity \\(field varchar.+, b boolean.+, c varchar.+, lob clob.+" );
String fileContent = new String( Files.readAllBytes( this.output.toPath() ) );
Pattern fileContentPattern = Pattern
.compile( "create( (column|row))? table test_entity \\(field " + this.varcharType + ".+, b boolean.+, c " + this.varcharType + ".+, lob " + this.clobType + ".+" );
Matcher fileContentMatcher = fileContentPattern.matcher( fileContent.toLowerCase() );
assertThat(
"Script file : " + fileContent.toLowerCase(),
@ -103,7 +108,7 @@ public class HANASchemaMigrationTargetScriptCreationTest extends BaseCoreFunctio
this.rebuildSessionFactory( config -> {
config.setProperty( "hibernate.dialect.hana.use_unicode_string_types", "true" );
} );
String fileContent = new String( Files.readAllBytes( output.toPath() ) );
String fileContent = new String( Files.readAllBytes( this.output.toPath() ) );
Pattern fileContentPattern = Pattern.compile( "create( (column|row))? table test_entity \\(field nvarchar.+, b boolean.+, c nvarchar.+, lob nclob" );
Matcher fileContentMatcher = fileContentPattern.matcher( fileContent.toLowerCase() );
assertThat(
@ -116,23 +121,23 @@ public class HANASchemaMigrationTargetScriptCreationTest extends BaseCoreFunctio
@TestForIssue(jiraKey = "HHH-12302")
public void testTargetScriptIsCreatedStringTypeVarchar() throws Exception {
this.rebuildSessionFactory( config -> {
config.setProperty( "hibernate.dialect.hana.use_nvarchar_string_type", "false" );
config.setProperty( "hibernate.dialect.hana.use_unicode_string_types", "false" );
} );
String fileContent = new String( Files.readAllBytes( output.toPath() ) );
Pattern fileContentPattern = Pattern.compile( "create( (column|row))? table test_entity \\(field varchar.+, b boolean.+, c varchar.+, lob clob" );
String fileContent = new String( Files.readAllBytes( this.output.toPath() ) );
Pattern fileContentPattern = Pattern.compile( "create( (column|row))? table test_entity \\(field " + this.varcharType + ".+, b boolean.+, c " + this.varcharType + ".+, lob " + this.clobType );
Matcher fileContentMatcher = fileContentPattern.matcher( fileContent.toLowerCase() );
assertThat(
"Script file : " + fileContent.toLowerCase(),
fileContentMatcher.find(),
is( true ) );
}
@Test
@TestForIssue(jiraKey = "HHH-12132")
public void testTargetScriptIsCreatedBooleanTypeDefault() throws Exception {
this.rebuildSessionFactory();
String fileContent = new String( Files.readAllBytes( output.toPath() ) );
Pattern fileContentPattern = Pattern.compile( "create( (column|row))? table test_entity \\(field varchar.+, b boolean.+, c varchar.+, lob clob" );
String fileContent = new String( Files.readAllBytes( this.output.toPath() ) );
Pattern fileContentPattern = Pattern.compile( "create( (column|row))? table test_entity \\(field " + this.varcharType + ".+, b boolean.+, c " + this.varcharType + ".+, lob " + this.clobType );
Matcher fileContentMatcher = fileContentPattern.matcher( fileContent.toLowerCase() );
assertThat(
"Script file : " + fileContent.toLowerCase(),
@ -146,8 +151,8 @@ public class HANASchemaMigrationTargetScriptCreationTest extends BaseCoreFunctio
this.rebuildSessionFactory( config -> {
config.setProperty( "hibernate.dialect.hana.use_legacy_boolean_type", "true" );
} );
String fileContent = new String( Files.readAllBytes( output.toPath() ) );
Pattern fileContentPattern = Pattern.compile( "create( (column|row))? table test_entity \\(field varchar.+, b tinyint.+, c varchar.+, lob clob" );
String fileContent = new String( Files.readAllBytes( this.output.toPath() ) );
Pattern fileContentPattern = Pattern.compile( "create( (column|row))? table test_entity \\(field " + this.varcharType + ".+, b tinyint.+, c " + this.varcharType + ".+, lob " + this.clobType );
Matcher fileContentMatcher = fileContentPattern.matcher( fileContent.toLowerCase() );
assertThat(
"Script file : " + fileContent.toLowerCase(),
@ -161,8 +166,8 @@ public class HANASchemaMigrationTargetScriptCreationTest extends BaseCoreFunctio
this.rebuildSessionFactory( config -> {
config.setProperty( "hibernate.dialect.hana.use_legacy_boolean_type", "false" );
} );
String fileContent = new String( Files.readAllBytes( output.toPath() ) );
Pattern fileContentPattern = Pattern.compile( "create( (column|row))? table test_entity \\(field varchar.+, b boolean.+, c varchar.+, lob clob" );
String fileContent = new String( Files.readAllBytes( this.output.toPath() ) );
Pattern fileContentPattern = Pattern.compile( "create( (column|row))? table test_entity \\(field " + this.varcharType + ".+, b boolean.+, c " + this.varcharType + ".+, lob " + this.clobType );
Matcher fileContentMatcher = fileContentPattern.matcher( fileContent.toLowerCase() );
assertThat(
"Script file : " + fileContent.toLowerCase(),
@ -181,7 +186,7 @@ public class HANASchemaMigrationTargetScriptCreationTest extends BaseCoreFunctio
@Lob
private String lob;
private boolean b;
}
}