Merge remote-tracking branch 'upstream/master' into wip/6.0_merge_32

This commit is contained in:
Andrea Boriero 2020-04-17 14:39:36 +01:00
commit 7ced01d303
11 changed files with 218 additions and 51 deletions

View File

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

View File

@ -109,6 +109,13 @@ ext {
'jdbc.pass' : 'H1bernate_test', 'jdbc.pass' : 'H1bernate_test',
'jdbc.url' : 'jdbc:sap://localhost:30015/' '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 : [ hana_vlad : [
'db.dialect' : 'org.hibernate.dialect.HANAColumnStoreDialect', 'db.dialect' : 'org.hibernate.dialect.HANAColumnStoreDialect',
'jdbc.driver': 'com.sap.db.jdbc.Driver', 'jdbc.driver': 'com.sap.db.jdbc.Driver',

View File

@ -644,18 +644,17 @@ public abstract class AbstractHANADialect extends Dialect {
private static final int MAX_LOB_PREFETCH_SIZE_DEFAULT_VALUE = 1024; 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_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 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 HANANClobTypeDescriptor nClobTypeDescriptor = new HANANClobTypeDescriptor( MAX_LOB_PREFETCH_SIZE_DEFAULT_VALUE );
private HANABlobTypeDescriptor blobTypeDescriptor = new HANABlobTypeDescriptor( 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, private HANAClobTypeDescriptor clobTypeDescriptor;
USE_UNICODE_STRING_TYPES_DEFAULT_VALUE.booleanValue() );
private boolean useLegacyBooleanType = USE_LEGACY_BOOLEAN_TYPE_DEFAULT_VALUE.booleanValue(); 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(); private boolean treatDoubleTypedFieldsAsDecimal = TREAT_DOUBLE_TYPED_FIELDS_AS_DECIMAL_DEFAULT_VALUE.booleanValue();
/* /*
@ -701,6 +700,11 @@ public abstract class AbstractHANADialect extends Dialect {
public AbstractHANADialect() { public AbstractHANADialect() {
super(); super();
this.useUnicodeStringTypes = useUnicodeStringTypesDefault().booleanValue();
this.clobTypeDescriptor = new HANAClobTypeDescriptor( MAX_LOB_PREFETCH_SIZE_DEFAULT_VALUE,
useUnicodeStringTypesDefault().booleanValue() );
registerColumnType( Types.DECIMAL, "decimal($p, $s)" );
//there is no 'numeric' type in HANA //there is no 'numeric' type in HANA
registerColumnType( Types.NUMERIC, "decimal($p, $s)" ); registerColumnType( Types.NUMERIC, "decimal($p, $s)" );
@ -738,7 +742,7 @@ public abstract class AbstractHANADialect extends Dialect {
registerHibernateType( Types.NCLOB, StandardBasicTypes.MATERIALIZED_NCLOB.getName() ); registerHibernateType( Types.NCLOB, StandardBasicTypes.MATERIALIZED_NCLOB.getName() );
registerHibernateType( Types.CLOB, StandardBasicTypes.MATERIALIZED_CLOB.getName() ); registerHibernateType( Types.CLOB, StandardBasicTypes.MATERIALIZED_CLOB.getName() );
registerHibernateType( Types.BLOB, StandardBasicTypes.MATERIALIZED_BLOB.getName() ); registerHibernateType( Types.BLOB, StandardBasicTypes.MATERIALIZED_BLOB.getName() );
registerHibernateType( Types.NVARCHAR, StandardBasicTypes.STRING.getName() ); registerHibernateType( Types.NVARCHAR, StandardBasicTypes.NSTRING.getName() );
registerHanaKeywords(); registerHanaKeywords();
@ -974,9 +978,9 @@ public abstract class AbstractHANADialect extends Dialect {
case Types.BOOLEAN: case Types.BOOLEAN:
return this.useLegacyBooleanType ? BitTypeDescriptor.INSTANCE : BooleanTypeDescriptor.INSTANCE; return this.useLegacyBooleanType ? BitTypeDescriptor.INSTANCE : BooleanTypeDescriptor.INSTANCE;
case Types.VARCHAR: case Types.VARCHAR:
return this.useUnicodeStringTypes ? NVarcharTypeDescriptor.INSTANCE : VarcharTypeDescriptor.INSTANCE; return this.isUseUnicodeStringTypes() ? NVarcharTypeDescriptor.INSTANCE : VarcharTypeDescriptor.INSTANCE;
case Types.CHAR: case Types.CHAR:
return this.useUnicodeStringTypes ? NCharTypeDescriptor.INSTANCE : CharTypeDescriptor.INSTANCE; return this.isUseUnicodeStringTypes() ? NCharTypeDescriptor.INSTANCE : CharTypeDescriptor.INSTANCE;
case Types.DOUBLE: case Types.DOUBLE:
return this.treatDoubleTypedFieldsAsDecimal ? DecimalTypeDescriptor.INSTANCE : DoubleTypeDescriptor.INSTANCE; return this.treatDoubleTypedFieldsAsDecimal ? DecimalTypeDescriptor.INSTANCE : DoubleTypeDescriptor.INSTANCE;
default: default:
@ -1398,10 +1402,14 @@ public abstract class AbstractHANADialect extends Dialect {
this.blobTypeDescriptor = new HANABlobTypeDescriptor( maxLobPrefetchSize ); this.blobTypeDescriptor = new HANABlobTypeDescriptor( maxLobPrefetchSize );
} }
this.useUnicodeStringTypes = configurationService.getSetting( USE_UNICODE_STRING_TYPES_PARAMETER_NAME, StandardConverters.BOOLEAN, if ( supportsAsciiStringTypes() ) {
USE_UNICODE_STRING_TYPES_DEFAULT_VALUE ).booleanValue(); this.useUnicodeStringTypes = configurationService.getSetting(
USE_UNICODE_STRING_TYPES_PARAMETER_NAME,
StandardConverters.BOOLEAN,
useUnicodeStringTypesDefault()
).booleanValue();
if ( this.useUnicodeStringTypes ) { if ( this.isUseUnicodeStringTypes() ) {
registerColumnType( Types.CHAR, "nvarchar($l)" ); registerColumnType( Types.CHAR, "nvarchar($l)" );
registerColumnType( Types.VARCHAR, 5000, "nvarchar($l)" ); registerColumnType( Types.VARCHAR, 5000, "nvarchar($l)" );
@ -1414,6 +1422,7 @@ public abstract class AbstractHANADialect extends Dialect {
|| this.clobTypeDescriptor.isUseUnicodeStringTypes() != this.useUnicodeStringTypes ) { || this.clobTypeDescriptor.isUseUnicodeStringTypes() != this.useUnicodeStringTypes ) {
this.clobTypeDescriptor = new HANAClobTypeDescriptor( maxLobPrefetchSize, this.useUnicodeStringTypes ); this.clobTypeDescriptor = new HANAClobTypeDescriptor( maxLobPrefetchSize, this.useUnicodeStringTypes );
} }
}
this.useLegacyBooleanType = configurationService.getSetting( USE_LEGACY_BOOLEAN_TYPE_PARAMETER_NAME, StandardConverters.BOOLEAN, this.useLegacyBooleanType = configurationService.getSetting( USE_LEGACY_BOOLEAN_TYPE_PARAMETER_NAME, StandardConverters.BOOLEAN,
USE_LEGACY_BOOLEAN_TYPE_DEFAULT_VALUE ).booleanValue(); USE_LEGACY_BOOLEAN_TYPE_DEFAULT_VALUE ).booleanValue();
@ -1483,6 +1492,7 @@ public abstract class AbstractHANADialect extends Dialect {
return false; return false;
} }
@Override
public boolean supportsNoColumnsInsert() { public boolean supportsNoColumnsInsert() {
return false; return false;
} }
@ -1492,4 +1502,12 @@ public abstract class AbstractHANADialect extends Dialect {
//I don't think HANA needs FM //I don't think HANA needs FM
return OracleDialect.datetimeFormat( format, false ).result(); return OracleDialect.datetimeFormat( format, false ).result();
} }
public boolean isUseUnicodeStringTypes() {
return this.useUnicodeStringTypes;
}
protected abstract boolean supportsAsciiStringTypes();
protected abstract Boolean useUnicodeStringTypesDefault();
} }

View File

@ -0,0 +1,108 @@
/*
* 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.query.spi.QueryEngine;
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();
}
@Override
public void initializeFunctionRegistry(QueryEngine queryEngine) {
super.initializeFunctionRegistry( queryEngine );
// full-text search functions
queryEngine.getSqmFunctionRegistry().registerNamed( "score", StandardBasicTypes.DOUBLE );
queryEngine.getSqmFunctionRegistry().registerNamed( "snippets" );
queryEngine.getSqmFunctionRegistry().registerNamed( "highlighted" );
// queryEngine.getSqmFunctionRegistry().registerVarArgs( "contains", StandardSpiBasicTypes.BOOLEAN, "contains(", ",", ") /*" );
// queryEngine.getSqmFunctionRegistry().registerPattern( "contains_rhs", "*/", StandardSpiBasicTypes.BOOLEAN );
// queryEngine.getSqmFunctionRegistry().registerVarArgs( "not_contains", StandardSpiBasicTypes.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
protected boolean supportsAsciiStringTypes() {
return false;
}
@Override
protected Boolean useUnicodeStringTypesDefault() {
return Boolean.TRUE;
}
@Override
public boolean isUseUnicodeStringTypes() {
return true;
}
}

View File

@ -75,4 +75,14 @@ public class HANAColumnStoreDialect extends AbstractHANADialect {
runtimeModelCreationContext.getSessionFactory() runtimeModelCreationContext.getSessionFactory()
); );
} }
@Override
protected boolean supportsAsciiStringTypes() {
return true;
}
@Override
protected Boolean useUnicodeStringTypesDefault() {
return Boolean.FALSE;
}
} }

View File

@ -55,4 +55,14 @@ public class HANARowStoreDialect extends AbstractHANADialect {
runtimeModelCreationContext.getSessionFactory() runtimeModelCreationContext.getSessionFactory()
); );
} }
@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.boot.spi.MetadataImplementor;
import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.AvailableSettings;
import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Configuration;
import org.hibernate.dialect.HANACloudColumnStoreDialect;
import org.hibernate.internal.util.ConfigHelper; import org.hibernate.internal.util.ConfigHelper;
import org.hibernate.mapping.BasicValue; import org.hibernate.mapping.BasicValue;
import org.hibernate.mapping.PersistentClass; import org.hibernate.mapping.PersistentClass;
@ -331,7 +332,12 @@ public class AttributeConverterTest extends BaseUnitTestCase {
} }
AbstractStandardBasicType basicType = assertTyping( AbstractStandardBasicType.class, type ); AbstractStandardBasicType basicType = assertTyping( AbstractStandardBasicType.class, type );
assertTyping( EnumJavaTypeDescriptor.class, basicType.getJavaTypeDescriptor() ); assertTyping( EnumJavaTypeDescriptor.class, basicType.getJavaTypeDescriptor() );
if (metadata.getDatabase().getDialect() instanceof HANACloudColumnStoreDialect) {
assertEquals( Types.NVARCHAR, basicType.getSqlTypeDescriptor().getSqlType() );
}
else {
assertEquals( Types.VARCHAR, basicType.getSqlTypeDescriptor().getSqlType() ); assertEquals( Types.VARCHAR, basicType.getSqlTypeDescriptor().getSqlType() );
}
// then lets build the SF and verify its use... // then lets build the SF and verify its use...
final SessionFactory sf = metadata.buildSessionFactory(); final SessionFactory sf = metadata.buildSessionFactory();

View File

@ -14,10 +14,11 @@ import java.sql.PreparedStatement;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.Id; import javax.persistence.Id;
import org.hibernate.Session; import org.hibernate.dialect.HANACloudColumnStoreDialect;
import org.hibernate.dialect.HANAColumnStoreDialect; import org.hibernate.dialect.HANAColumnStoreDialect;
import org.hibernate.query.Query; import org.hibernate.query.Query;
import org.hibernate.testing.RequiresDialect; import org.hibernate.testing.RequiresDialect;
import org.hibernate.testing.SkipForDialect;
import org.hibernate.testing.TestForIssue; import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.junit.Test; import org.junit.Test;
@ -28,6 +29,7 @@ import org.junit.Test;
* @author Jonathan Bregler * @author Jonathan Bregler
*/ */
@RequiresDialect(value = { HANAColumnStoreDialect.class }) @RequiresDialect(value = { HANAColumnStoreDialect.class })
@SkipForDialect(value = HANACloudColumnStoreDialect.class)
public class HANASearchTest extends BaseCoreFunctionalTestCase { public class HANASearchTest extends BaseCoreFunctionalTestCase {
private static final String ENTITY_NAME = "SearchEntity"; private static final String ENTITY_NAME = "SearchEntity";

View File

@ -24,7 +24,7 @@ import static org.junit.Assert.fail;
public class HANANoColumnInsertTest extends BaseCoreFunctionalTestCase { public class HANANoColumnInsertTest extends BaseCoreFunctionalTestCase {
public String[] getMappings() { public String[] getMappings() {
return new String[] { return new String[]{
"ops/Competition.hbm.xml" "ops/Competition.hbm.xml"
}; };
} }
@ -34,10 +34,12 @@ public class HANANoColumnInsertTest extends BaseCoreFunctionalTestCase {
try { try {
super.buildSessionFactory(); super.buildSessionFactory();
fail("Should have thrown MappingException!"); fail( "Should have thrown MappingException!" );
} }
catch (MappingException e) { 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 { public void test() throws Exception {
} }
} }

View File

@ -94,7 +94,7 @@ public class QueryHintHANATest extends BaseNonConfigCoreFunctionalTestCase {
doInHibernate( this::sessionFactory, s -> { doInHibernate( this::sessionFactory, s -> {
Query<Employee> query = s.createQuery( "FROM QueryHintHANATest$Employee e WHERE e.department.name = :departmentName", Employee.class ) Query<Employee> query = s.createQuery( "FROM QueryHintHANATest$Employee e WHERE e.department.name = :departmentName", Employee.class )
.addQueryHint( "NO_CS_JOIN" ) .addQueryHint( "NO_CS_JOIN" )
.addQueryHint( "OPTIMIZE_METAMODEL" ) .addQueryHint( "IGNORE_PLAN_CACHE" )
.setParameter( "departmentName", "Sales" ); .setParameter( "departmentName", "Sales" );
List<Employee> results = query.list(); List<Employee> results = query.list();
@ -103,7 +103,7 @@ public class QueryHintHANATest extends BaseNonConfigCoreFunctionalTestCase {
sqlStatementInterceptor.assertExecutedCount( 1 ); 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(); sqlStatementInterceptor.clear();
// ensure the insertion logic can handle a comment appended to the front // 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 { public class HANASchemaMigrationTargetScriptCreationTest extends BaseCoreFunctionalTestCase {
private File output; private File output;
private String varcharType;
private String clobType;
@Override @Override
protected Class<?>[] getAnnotatedClasses() { protected Class<?>[] getAnnotatedClasses() {
@ -58,14 +60,16 @@ public class HANASchemaMigrationTargetScriptCreationTest extends BaseCoreFunctio
@Override @Override
protected void configure(Configuration configuration) { protected void configure(Configuration configuration) {
try { try {
output = File.createTempFile( "update_script", ".sql" ); this.output = File.createTempFile( "update_script", ".sql" );
} }
catch (IOException e) { catch (IOException e) {
fail( e.getMessage() ); fail( e.getMessage() );
} }
output.deleteOnExit(); this.output.deleteOnExit();
configuration.setProperty( Environment.HBM2DDL_SCRIPTS_ACTION, "create" ); 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 @After
@ -88,8 +92,9 @@ public class HANASchemaMigrationTargetScriptCreationTest extends BaseCoreFunctio
@TestForIssue(jiraKey = "HHH-12302") @TestForIssue(jiraKey = "HHH-12302")
public void testTargetScriptIsCreatedStringTypeDefault() throws Exception { public void testTargetScriptIsCreatedStringTypeDefault() throws Exception {
this.rebuildSessionFactory(); this.rebuildSessionFactory();
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 varchar.+, b boolean.+, c varchar.+, lob clob.+" ); 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() ); Matcher fileContentMatcher = fileContentPattern.matcher( fileContent.toLowerCase() );
assertThat( assertThat(
"Script file : " + fileContent.toLowerCase(), "Script file : " + fileContent.toLowerCase(),
@ -103,7 +108,7 @@ public class HANASchemaMigrationTargetScriptCreationTest extends BaseCoreFunctio
this.rebuildSessionFactory( config -> { this.rebuildSessionFactory( config -> {
config.setProperty( "hibernate.dialect.hana.use_unicode_string_types", "true" ); 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" ); Pattern fileContentPattern = Pattern.compile( "create( (column|row))? table test_entity \\(field nvarchar.+, b boolean.+, c nvarchar.+, lob nclob" );
Matcher fileContentMatcher = fileContentPattern.matcher( fileContent.toLowerCase() ); Matcher fileContentMatcher = fileContentPattern.matcher( fileContent.toLowerCase() );
assertThat( assertThat(
@ -116,10 +121,10 @@ public class HANASchemaMigrationTargetScriptCreationTest extends BaseCoreFunctio
@TestForIssue(jiraKey = "HHH-12302") @TestForIssue(jiraKey = "HHH-12302")
public void testTargetScriptIsCreatedStringTypeVarchar() throws Exception { public void testTargetScriptIsCreatedStringTypeVarchar() throws Exception {
this.rebuildSessionFactory( config -> { 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() ) ); String fileContent = new String( Files.readAllBytes( this.output.toPath() ) );
Pattern fileContentPattern = Pattern.compile( "create( (column|row))? table test_entity \\(field varchar.+, b boolean.+, c varchar.+, lob clob" ); 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() ); Matcher fileContentMatcher = fileContentPattern.matcher( fileContent.toLowerCase() );
assertThat( assertThat(
"Script file : " + fileContent.toLowerCase(), "Script file : " + fileContent.toLowerCase(),
@ -131,8 +136,8 @@ public class HANASchemaMigrationTargetScriptCreationTest extends BaseCoreFunctio
@TestForIssue(jiraKey = "HHH-12132") @TestForIssue(jiraKey = "HHH-12132")
public void testTargetScriptIsCreatedBooleanTypeDefault() throws Exception { public void testTargetScriptIsCreatedBooleanTypeDefault() throws Exception {
this.rebuildSessionFactory(); this.rebuildSessionFactory();
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 varchar.+, b boolean.+, c varchar.+, lob clob" ); 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() ); Matcher fileContentMatcher = fileContentPattern.matcher( fileContent.toLowerCase() );
assertThat( assertThat(
"Script file : " + fileContent.toLowerCase(), "Script file : " + fileContent.toLowerCase(),
@ -146,8 +151,8 @@ public class HANASchemaMigrationTargetScriptCreationTest extends BaseCoreFunctio
this.rebuildSessionFactory( config -> { this.rebuildSessionFactory( config -> {
config.setProperty( "hibernate.dialect.hana.use_legacy_boolean_type", "true" ); config.setProperty( "hibernate.dialect.hana.use_legacy_boolean_type", "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 varchar.+, b tinyint.+, c varchar.+, lob clob" ); 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() ); Matcher fileContentMatcher = fileContentPattern.matcher( fileContent.toLowerCase() );
assertThat( assertThat(
"Script file : " + fileContent.toLowerCase(), "Script file : " + fileContent.toLowerCase(),
@ -161,8 +166,8 @@ public class HANASchemaMigrationTargetScriptCreationTest extends BaseCoreFunctio
this.rebuildSessionFactory( config -> { this.rebuildSessionFactory( config -> {
config.setProperty( "hibernate.dialect.hana.use_legacy_boolean_type", "false" ); config.setProperty( "hibernate.dialect.hana.use_legacy_boolean_type", "false" );
} ); } );
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 varchar.+, b boolean.+, c varchar.+, lob clob" ); 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() ); Matcher fileContentMatcher = fileContentPattern.matcher( fileContent.toLowerCase() );
assertThat( assertThat(
"Script file : " + fileContent.toLowerCase(), "Script file : " + fileContent.toLowerCase(),