Fix some test issues with HANA and emulate derived table column naming on HANA
This commit is contained in:
parent
39484b160d
commit
29bfb799aa
|
@ -17,6 +17,7 @@ import org.hibernate.metamodel.MappingMetamodel;
|
|||
import org.hibernate.metamodel.mapping.JdbcMapping;
|
||||
import org.hibernate.metamodel.mapping.internal.BasicAttributeMapping;
|
||||
import org.hibernate.persister.entity.EntityPersister;
|
||||
import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry;
|
||||
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||
|
@ -35,31 +36,32 @@ public class CharacterArrayMappingTests {
|
|||
@Test
|
||||
public void verifyMappings(SessionFactoryScope scope) {
|
||||
final MappingMetamodel domainModel = scope.getSessionFactory().getDomainModel();
|
||||
final JdbcTypeRegistry jdbcRegistry = domainModel.getTypeConfiguration().getJdbcTypeDescriptorRegistry();
|
||||
final EntityPersister entityDescriptor = domainModel.findEntityDescriptor( EntityWithCharArrays.class );
|
||||
|
||||
{
|
||||
final BasicAttributeMapping attributeMapping = (BasicAttributeMapping) entityDescriptor.findAttributeMapping( "primitive" );
|
||||
final JdbcMapping jdbcMapping = attributeMapping.getJdbcMapping();
|
||||
assertThat( jdbcMapping.getJdbcTypeDescriptor().getJdbcTypeCode(), equalTo( Types.VARCHAR ) );
|
||||
assertThat( jdbcMapping.getJdbcTypeDescriptor(), equalTo( jdbcRegistry.getDescriptor( Types.VARCHAR ) ) );
|
||||
}
|
||||
|
||||
{
|
||||
final BasicAttributeMapping attributeMapping = (BasicAttributeMapping) entityDescriptor.findAttributeMapping( "wrapper" );
|
||||
final JdbcMapping jdbcMapping = attributeMapping.getJdbcMapping();
|
||||
assertThat( jdbcMapping.getJdbcTypeDescriptor().getJdbcTypeCode(), equalTo( Types.VARCHAR ) );
|
||||
assertThat( jdbcMapping.getJdbcTypeDescriptor(), equalTo( jdbcRegistry.getDescriptor( Types.VARCHAR ) ) );
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
final BasicAttributeMapping attributeMapping = (BasicAttributeMapping) entityDescriptor.findAttributeMapping( "primitiveClob" );
|
||||
final JdbcMapping jdbcMapping = attributeMapping.getJdbcMapping();
|
||||
assertThat( jdbcMapping.getJdbcTypeDescriptor().getJdbcTypeCode(), equalTo( Types.CLOB ) );
|
||||
assertThat( jdbcMapping.getJdbcTypeDescriptor(), equalTo( jdbcRegistry.getDescriptor( Types.CLOB ) ) );
|
||||
}
|
||||
|
||||
{
|
||||
final BasicAttributeMapping attributeMapping = (BasicAttributeMapping) entityDescriptor.findAttributeMapping( "wrapperClob" );
|
||||
final JdbcMapping jdbcMapping = attributeMapping.getJdbcMapping();
|
||||
assertThat( jdbcMapping.getJdbcTypeDescriptor().getJdbcTypeCode(), equalTo( Types.CLOB ) );
|
||||
assertThat( jdbcMapping.getJdbcTypeDescriptor(), equalTo( jdbcRegistry.getDescriptor( Types.CLOB ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ import org.hibernate.metamodel.MappingMetamodel;
|
|||
import org.hibernate.metamodel.mapping.JdbcMapping;
|
||||
import org.hibernate.metamodel.mapping.internal.BasicAttributeMapping;
|
||||
import org.hibernate.persister.entity.EntityPersister;
|
||||
import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry;
|
||||
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||
|
@ -41,6 +42,7 @@ public class CharacterMappingTests {
|
|||
public void testMappings(SessionFactoryScope scope) {
|
||||
// first, verify the type selections...
|
||||
final MappingMetamodel domainModel = scope.getSessionFactory().getDomainModel();
|
||||
final JdbcTypeRegistry jdbcRegistry = domainModel.getTypeConfiguration().getJdbcTypeDescriptorRegistry();
|
||||
final EntityPersister entityDescriptor = domainModel.findEntityDescriptor( EntityOfCharacters.class );
|
||||
|
||||
{
|
||||
|
@ -49,7 +51,7 @@ public class CharacterMappingTests {
|
|||
|
||||
final JdbcMapping jdbcMapping = attribute.getJdbcMapping();
|
||||
assertThat( jdbcMapping.getJavaTypeDescriptor().getJavaTypeClass(), equalTo( Character.class ) );
|
||||
assertThat( jdbcMapping.getJdbcTypeDescriptor().getJdbcTypeCode(), equalTo( Types.CHAR ) );
|
||||
assertThat( jdbcMapping.getJdbcTypeDescriptor(), equalTo( jdbcRegistry.getDescriptor( Types.CHAR ) ) );
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -58,7 +60,7 @@ public class CharacterMappingTests {
|
|||
|
||||
final JdbcMapping jdbcMapping = attribute.getJdbcMapping();
|
||||
assertThat( jdbcMapping.getJavaTypeDescriptor().getJavaTypeClass(), equalTo( Character.class ) );
|
||||
assertThat( jdbcMapping.getJdbcTypeDescriptor().getJdbcTypeCode(), equalTo( Types.CHAR ) );
|
||||
assertThat( jdbcMapping.getJdbcTypeDescriptor(), equalTo( jdbcRegistry.getDescriptor( Types.CHAR ) ) );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ import org.hibernate.metamodel.MappingMetamodel;
|
|||
import org.hibernate.metamodel.mapping.JdbcMapping;
|
||||
import org.hibernate.metamodel.mapping.internal.BasicAttributeMapping;
|
||||
import org.hibernate.persister.entity.EntityPersister;
|
||||
import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry;
|
||||
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||
|
@ -35,12 +36,13 @@ public class ClassMappingTests {
|
|||
@Test
|
||||
public void verifyMappings(SessionFactoryScope scope) {
|
||||
final MappingMetamodel domainModel = scope.getSessionFactory().getDomainModel();
|
||||
final JdbcTypeRegistry jdbcRegistry = domainModel.getTypeConfiguration().getJdbcTypeDescriptorRegistry();
|
||||
final EntityPersister entityDescriptor = domainModel.findEntityDescriptor( EntityWithClass.class );
|
||||
|
||||
final BasicAttributeMapping duration = (BasicAttributeMapping) entityDescriptor.findAttributeMapping( "clazz" );
|
||||
final JdbcMapping jdbcMapping = duration.getJdbcMapping();
|
||||
assertThat( jdbcMapping.getJavaTypeDescriptor().getJavaTypeClass(), equalTo( Class.class ) );
|
||||
assertThat( jdbcMapping.getJdbcTypeDescriptor().getJdbcTypeCode(), equalTo( Types.VARCHAR ) );
|
||||
assertThat( jdbcMapping.getJdbcTypeDescriptor(), equalTo( jdbcRegistry.getDescriptor( Types.VARCHAR ) ) );
|
||||
|
||||
scope.inTransaction(
|
||||
(session) -> {
|
||||
|
|
|
@ -16,6 +16,7 @@ import org.hibernate.metamodel.MappingMetamodel;
|
|||
import org.hibernate.metamodel.mapping.JdbcMapping;
|
||||
import org.hibernate.metamodel.mapping.internal.BasicAttributeMapping;
|
||||
import org.hibernate.persister.entity.EntityPersister;
|
||||
import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry;
|
||||
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||
|
@ -35,12 +36,13 @@ public class CurrencyMappingTests {
|
|||
@Test
|
||||
public void verifyMappings(SessionFactoryScope scope) {
|
||||
final MappingMetamodel domainModel = scope.getSessionFactory().getDomainModel();
|
||||
final JdbcTypeRegistry jdbcRegistry = domainModel.getTypeConfiguration().getJdbcTypeDescriptorRegistry();
|
||||
final EntityPersister entityDescriptor = domainModel.findEntityDescriptor( EntityWithCurrency.class );
|
||||
|
||||
final BasicAttributeMapping duration = (BasicAttributeMapping) entityDescriptor.findAttributeMapping( "currency" );
|
||||
final JdbcMapping jdbcMapping = duration.getJdbcMapping();
|
||||
assertThat( jdbcMapping.getJavaTypeDescriptor().getJavaTypeClass(), equalTo( Currency.class ) );
|
||||
assertThat( jdbcMapping.getJdbcTypeDescriptor().getJdbcTypeCode(), equalTo( Types.VARCHAR ) );
|
||||
assertThat( jdbcMapping.getJdbcTypeDescriptor(), equalTo( jdbcRegistry.getDescriptor( Types.VARCHAR ) ) );
|
||||
|
||||
scope.inTransaction(
|
||||
(session) -> {
|
||||
|
|
|
@ -17,6 +17,7 @@ import org.hibernate.metamodel.MappingMetamodel;
|
|||
import org.hibernate.metamodel.mapping.JdbcMapping;
|
||||
import org.hibernate.metamodel.mapping.internal.BasicAttributeMapping;
|
||||
import org.hibernate.persister.entity.EntityPersister;
|
||||
import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry;
|
||||
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||
|
@ -36,12 +37,13 @@ public class LocaleMappingTests {
|
|||
@Test
|
||||
public void verifyMappings(SessionFactoryScope scope) {
|
||||
final MappingMetamodel domainModel = scope.getSessionFactory().getDomainModel();
|
||||
final JdbcTypeRegistry jdbcRegistry = domainModel.getTypeConfiguration().getJdbcTypeDescriptorRegistry();
|
||||
final EntityPersister entityDescriptor = domainModel.findEntityDescriptor( EntityWithLocale.class );
|
||||
|
||||
final BasicAttributeMapping duration = (BasicAttributeMapping) entityDescriptor.findAttributeMapping( "locale" );
|
||||
final JdbcMapping jdbcMapping = duration.getJdbcMapping();
|
||||
assertThat( jdbcMapping.getJavaTypeDescriptor().getJavaTypeClass(), equalTo( Locale.class ) );
|
||||
assertThat( jdbcMapping.getJdbcTypeDescriptor().getJdbcTypeCode(), equalTo( Types.VARCHAR ) );
|
||||
assertThat( jdbcMapping.getJdbcTypeDescriptor(), equalTo( jdbcRegistry.getDescriptor( Types.VARCHAR ) ) );
|
||||
|
||||
scope.inTransaction(
|
||||
(session) -> {
|
||||
|
|
|
@ -16,6 +16,7 @@ import org.hibernate.metamodel.MappingMetamodel;
|
|||
import org.hibernate.metamodel.mapping.JdbcMapping;
|
||||
import org.hibernate.metamodel.mapping.internal.BasicAttributeMapping;
|
||||
import org.hibernate.persister.entity.EntityPersister;
|
||||
import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry;
|
||||
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||
|
@ -39,6 +40,7 @@ public class StringMappingTests {
|
|||
public void testMappings(SessionFactoryScope scope) {
|
||||
// first, verify the type selections...
|
||||
final MappingMetamodel domainModel = scope.getSessionFactory().getDomainModel();
|
||||
final JdbcTypeRegistry jdbcRegistry = domainModel.getTypeConfiguration().getJdbcTypeDescriptorRegistry();
|
||||
final EntityPersister entityDescriptor = domainModel.findEntityDescriptor( EntityOfStrings.class );
|
||||
|
||||
{
|
||||
|
@ -47,14 +49,14 @@ public class StringMappingTests {
|
|||
|
||||
final JdbcMapping jdbcMapping = attribute.getJdbcMapping();
|
||||
assertThat( jdbcMapping.getJavaTypeDescriptor().getJavaTypeClass(), equalTo( String.class ) );
|
||||
assertThat( jdbcMapping.getJdbcTypeDescriptor().getJdbcTypeCode(), equalTo( Types.VARCHAR ) );
|
||||
assertThat( jdbcMapping.getJdbcTypeDescriptor(), equalTo( jdbcRegistry.getDescriptor( Types.VARCHAR ) ) );
|
||||
}
|
||||
|
||||
{
|
||||
final BasicAttributeMapping attribute = (BasicAttributeMapping) entityDescriptor.findAttributeMapping( "clobString" );
|
||||
final JdbcMapping jdbcMapping = attribute.getJdbcMapping();
|
||||
assertThat( jdbcMapping.getJavaTypeDescriptor().getJavaTypeClass(), equalTo( String.class ) );
|
||||
assertThat( jdbcMapping.getJdbcTypeDescriptor().getJdbcTypeCode(), equalTo( Types.CLOB ) );
|
||||
assertThat( jdbcMapping.getJdbcTypeDescriptor(), equalTo( jdbcRegistry.getDescriptor( Types.CLOB ) ) );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ import org.hibernate.metamodel.MappingMetamodel;
|
|||
import org.hibernate.metamodel.mapping.JdbcMapping;
|
||||
import org.hibernate.metamodel.mapping.internal.BasicAttributeMapping;
|
||||
import org.hibernate.persister.entity.EntityPersister;
|
||||
import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry;
|
||||
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||
|
@ -37,12 +38,13 @@ public class TimeZoneMappingTests {
|
|||
@Test
|
||||
public void verifyMappings(SessionFactoryScope scope) {
|
||||
final MappingMetamodel domainModel = scope.getSessionFactory().getDomainModel();
|
||||
final JdbcTypeRegistry jdbcRegistry = domainModel.getTypeConfiguration().getJdbcTypeDescriptorRegistry();
|
||||
final EntityPersister entityDescriptor = domainModel.findEntityDescriptor( EntityWithTimeZone.class );
|
||||
|
||||
final BasicAttributeMapping duration = (BasicAttributeMapping) entityDescriptor.findAttributeMapping( "timeZone" );
|
||||
final JdbcMapping jdbcMapping = duration.getJdbcMapping();
|
||||
assertThat( jdbcMapping.getJavaTypeDescriptor().getJavaTypeClass(), equalTo( TimeZone.class ) );
|
||||
assertThat( jdbcMapping.getJdbcTypeDescriptor().getJdbcTypeCode(), equalTo( Types.VARCHAR ) );
|
||||
assertThat( jdbcMapping.getJdbcTypeDescriptor(), equalTo( jdbcRegistry.getDescriptor( Types.VARCHAR ) ) );
|
||||
|
||||
scope.inTransaction(
|
||||
(session) -> {
|
||||
|
|
|
@ -17,6 +17,7 @@ import org.hibernate.metamodel.MappingMetamodel;
|
|||
import org.hibernate.metamodel.mapping.JdbcMapping;
|
||||
import org.hibernate.metamodel.mapping.internal.BasicAttributeMapping;
|
||||
import org.hibernate.persister.entity.EntityPersister;
|
||||
import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry;
|
||||
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||
|
@ -36,12 +37,13 @@ public class ZoneOffsetMappingTests {
|
|||
@Test
|
||||
public void verifyMappings(SessionFactoryScope scope) {
|
||||
final MappingMetamodel domainModel = scope.getSessionFactory().getDomainModel();
|
||||
final JdbcTypeRegistry jdbcRegistry = domainModel.getTypeConfiguration().getJdbcTypeDescriptorRegistry();
|
||||
final EntityPersister entityDescriptor = domainModel.findEntityDescriptor( EntityWithZoneOffset.class );
|
||||
|
||||
final BasicAttributeMapping duration = (BasicAttributeMapping) entityDescriptor.findAttributeMapping( "zoneOffset" );
|
||||
final JdbcMapping jdbcMapping = duration.getJdbcMapping();
|
||||
assertThat( jdbcMapping.getJavaTypeDescriptor().getJavaTypeClass(), equalTo( ZoneOffset.class ) );
|
||||
assertThat( jdbcMapping.getJdbcTypeDescriptor().getJdbcTypeCode(), equalTo( Types.VARCHAR ) );
|
||||
assertThat( jdbcMapping.getJdbcTypeDescriptor(), equalTo( jdbcRegistry.getDescriptor( Types.VARCHAR ) ) );
|
||||
|
||||
scope.inTransaction(
|
||||
(session) -> {
|
||||
|
|
|
@ -14,6 +14,8 @@ import org.hibernate.sql.ast.tree.cte.CteStatement;
|
|||
import org.hibernate.sql.ast.tree.expression.Expression;
|
||||
import org.hibernate.sql.ast.tree.expression.Literal;
|
||||
import org.hibernate.sql.ast.tree.expression.Summarization;
|
||||
import org.hibernate.sql.ast.tree.from.FunctionTableReference;
|
||||
import org.hibernate.sql.ast.tree.from.QueryPartTableReference;
|
||||
import org.hibernate.sql.ast.tree.select.QueryGroup;
|
||||
import org.hibernate.sql.ast.tree.select.QueryPart;
|
||||
import org.hibernate.sql.ast.tree.select.QuerySpec;
|
||||
|
@ -57,6 +59,17 @@ public class HANASqlAstTranslator<T extends JdbcOperation> extends AbstractSqlAs
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitQueryPartTableReference(QueryPartTableReference tableReference) {
|
||||
emulateQueryPartTableReferenceColumnAliasing( tableReference );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitFunctionTableReference(FunctionTableReference tableReference) {
|
||||
tableReference.getFunctionExpression().accept( this );
|
||||
renderTableReferenceIdentificationVariable( tableReference );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitOffsetFetchClause(QueryPart queryPart) {
|
||||
if ( !isRowNumberingCurrentQueryPart() ) {
|
||||
|
|
Loading…
Reference in New Issue