Skip to content

Commit

Permalink
Fix HANA test issues
Browse files Browse the repository at this point in the history
  • Loading branch information
beikov committed Feb 3, 2023
1 parent 5cbd7cd commit 895a9c8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1110,6 +1110,12 @@ public long getFractionalSecondPrecisionInNanos() {
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)";
Expand All @@ -1134,6 +1140,12 @@ public String timestampaddPattern(TemporalUnit unit, TemporalType temporalType,
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))";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
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;
Expand All @@ -41,6 +43,7 @@ public void testEnumTypeInterpretation() {
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" );
Expand All @@ -55,7 +58,10 @@ public void testEnumTypeInterpretation() {
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 );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
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;
Expand Down Expand Up @@ -214,6 +215,7 @@ <T> void queryById(String propertyName, long id, T value, Function<EntityWithArr

@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 -> {
Expand Down

0 comments on commit 895a9c8

Please sign in to comment.