Merge remote-tracking branch 'upstream/master' into wip/6.0_merge_32
This commit is contained in:
commit
7ced01d303
|
@ -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"} )
|
||||
|
|
|
@ -109,6 +109,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',
|
||||
|
|
|
@ -644,18 +644,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();
|
||||
|
||||
/*
|
||||
|
@ -701,6 +700,11 @@ 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)" );
|
||||
//there is no 'numeric' type in HANA
|
||||
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.CLOB, StandardBasicTypes.MATERIALIZED_CLOB.getName() );
|
||||
registerHibernateType( Types.BLOB, StandardBasicTypes.MATERIALIZED_BLOB.getName() );
|
||||
registerHibernateType( Types.NVARCHAR, StandardBasicTypes.STRING.getName() );
|
||||
registerHibernateType( Types.NVARCHAR, StandardBasicTypes.NSTRING.getName() );
|
||||
|
||||
registerHanaKeywords();
|
||||
|
||||
|
@ -974,9 +978,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:
|
||||
|
@ -1398,21 +1402,26 @@ 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($l)" );
|
||||
registerColumnType( Types.VARCHAR, 5000, "nvarchar($l)" );
|
||||
if ( this.isUseUnicodeStringTypes() ) {
|
||||
registerColumnType( Types.CHAR, "nvarchar($l)" );
|
||||
registerColumnType( Types.VARCHAR, 5000, "nvarchar($l)" );
|
||||
|
||||
// for longer values map to clob/nclob
|
||||
registerColumnType( Types.VARCHAR, "nclob" );
|
||||
registerColumnType( Types.CLOB, "nclob" );
|
||||
}
|
||||
// for longer values map to clob/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.useUnicodeStringTypes ) {
|
||||
this.clobTypeDescriptor = new HANAClobTypeDescriptor( maxLobPrefetchSize, this.useUnicodeStringTypes );
|
||||
}
|
||||
}
|
||||
|
||||
this.useLegacyBooleanType = configurationService.getSetting( USE_LEGACY_BOOLEAN_TYPE_PARAMETER_NAME, StandardConverters.BOOLEAN,
|
||||
|
@ -1483,6 +1492,7 @@ public abstract class AbstractHANADialect extends Dialect {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsNoColumnsInsert() {
|
||||
return false;
|
||||
}
|
||||
|
@ -1492,4 +1502,12 @@ public abstract class AbstractHANADialect extends Dialect {
|
|||
//I don't think HANA needs FM
|
||||
return OracleDialect.datetimeFormat( format, false ).result();
|
||||
}
|
||||
|
||||
public boolean isUseUnicodeStringTypes() {
|
||||
return this.useUnicodeStringTypes;
|
||||
}
|
||||
|
||||
protected abstract boolean supportsAsciiStringTypes();
|
||||
|
||||
protected abstract Boolean useUnicodeStringTypesDefault();
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -31,7 +31,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();
|
||||
}
|
||||
|
@ -75,4 +75,14 @@ public class HANAColumnStoreDialect extends AbstractHANADialect {
|
|||
runtimeModelCreationContext.getSessionFactory()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean supportsAsciiStringTypes() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Boolean useUnicodeStringTypesDefault() {
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,4 +55,14 @@ public class HANARowStoreDialect extends AbstractHANADialect {
|
|||
runtimeModelCreationContext.getSessionFactory()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean supportsAsciiStringTypes() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Boolean useUnicodeStringTypesDefault() {
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.internal.util.ConfigHelper;
|
||||
import org.hibernate.mapping.BasicValue;
|
||||
import org.hibernate.mapping.PersistentClass;
|
||||
|
@ -331,7 +332,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();
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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 {
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -94,7 +94,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();
|
||||
|
||||
|
@ -103,7 +103,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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue