Fix HANA test issues

This commit is contained in:
Christian Beikov 2023-02-02 18:04:21 +01:00
parent 9a1a703fa9
commit 5e8b43edf9
3 changed files with 21 additions and 1 deletions

View File

@ -1164,6 +1164,12 @@ public abstract class AbstractHANADialect extends Dialect {
public String timestampaddPattern(TemporalUnit unit, TemporalType temporalType, IntervalType intervalType) {
switch (unit) {
case NANOSECOND:
if ( temporalType == TemporalType.TIME ) {
return "cast(add_nano100('1970-01-01 '||(?3),?2/100) as time)";
}
else {
return "add_nano100(?3,?2/100)";
}
case NATIVE:
if ( temporalType == TemporalType.TIME ) {
return "cast(add_nano100('1970-01-01 '||(?3),?2) as time)";
@ -1188,6 +1194,12 @@ public abstract class AbstractHANADialect extends Dialect {
public String timestampdiffPattern(TemporalUnit unit, TemporalType fromTemporalType, TemporalType toTemporalType) {
switch (unit) {
case NANOSECOND:
// if ( temporalType == TemporalType.TIME ) {
// return "nano100_between(cast(?3 as timestamp), cast(?2 as timestamp))*100";
// }
// else {
return "nano100_between(?2,?3)*100";
// }
case NATIVE:
// if ( temporalType == TemporalType.TIME ) {
// return "nano100_between(cast(?3 as timestamp), cast(?2 as timestamp))";

View File

@ -20,6 +20,8 @@ import org.hibernate.mapping.Property;
import org.hibernate.mapping.SimpleValue;
import org.hibernate.mapping.Value;
import org.hibernate.type.CustomType;
import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry;
import org.hibernate.type.spi.TypeConfiguration;
import org.hibernate.testing.orm.junit.FailureExpected;
import org.junit.jupiter.api.Test;
@ -40,6 +42,7 @@ public class FieldAccessedNestedEmbeddableMetadataTest {
final Metadata metadata = new MetadataSources( ssr )
.addAnnotatedClass( Customer.class )
.buildMetadata();
final TypeConfiguration typeConfiguration = metadata.getDatabase().getTypeConfiguration();
PersistentClass classMetadata = metadata.getEntityBinding( Customer.class.getName() );
Property investmentsProperty = classMetadata.getProperty( "investments" );
@ -54,7 +57,10 @@ public class FieldAccessedNestedEmbeddableMetadataTest {
CustomType<Object> currencyType = (CustomType<Object>) currencyMetadata.getType();
int[] currencySqlTypes = currencyType.getSqlTypeCodes( metadata );
assertEquals( 1, currencySqlTypes.length );
assertJdbcTypeCode( Types.VARCHAR, currencySqlTypes[0] );
assertJdbcTypeCode(
typeConfiguration.getJdbcTypeRegistry().getDescriptor( Types.VARCHAR ).getJdbcTypeCode(),
currencySqlTypes[0]
);
}
finally {
StandardServiceRegistryBuilder.destroy( ssr );

View File

@ -13,6 +13,7 @@ import java.util.function.Function;
import java.util.stream.Stream;
import org.hibernate.annotations.JdbcTypeCode;
import org.hibernate.dialect.AbstractHANADialect;
import org.hibernate.dialect.OracleDialect;
import org.hibernate.dialect.SybaseDialect;
import org.hibernate.type.SqlTypes;
@ -214,6 +215,7 @@ public class VarbinaryArrayTest {
@ParameterizedTest
@MethodSource("perTypeArguments")
@SkipForDialect( dialectClass = AbstractHANADialect.class, matchSubTypes = true, reason = "For some reason, HANA can't intersect VARBINARY values, but funnily can do a union...")
<T> void queryByData(String propertyName, long id, T value, Function<EntityWithArrays, T> getter,
SessionFactoryScope scope) {
scope.inTransaction( session -> {