Skip to content
2 changes: 1 addition & 1 deletion gradle/databases.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ ext {
'jdbc.driver': 'com.informix.jdbc.IfxDriver',
'jdbc.user' : 'informix',
'jdbc.pass' : 'in4mix',
'jdbc.url' : 'jdbc:informix-sqli://' + dbHost + ':9088/dev:INFORMIXSERVER=informix;user=informix;password=in4mix;DELIMIDENT=Y;DB_LOCALE=en_US.utf8',
'jdbc.url' : 'jdbc:informix-sqli://' + dbHost + ':9088/dev:INFORMIXSERVER=informix;user=informix;password=in4mix;DBDATE=Y4MD-;DELIMIDENT=Y;DB_LOCALE=en_US.utf8',
'jdbc.datasource' : 'com.informix.jdbc.IfxDriver',
// 'jdbc.datasource' : 'com.informix.jdbcx.IfxDataSource',
'connection.init_sql' : ''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,13 @@
import org.hibernate.query.sqm.mutation.internal.temptable.LocalTemporaryTableMutationStrategy;
import org.hibernate.query.sqm.mutation.spi.SqmMultiTableInsertStrategy;
import org.hibernate.query.sqm.mutation.spi.SqmMultiTableMutationStrategy;
import org.hibernate.query.sqm.produce.function.StandardFunctionArgumentTypeResolvers;
import org.hibernate.query.sqm.sql.SqmTranslator;
import org.hibernate.query.sqm.sql.SqmTranslatorFactory;
import org.hibernate.query.sqm.sql.StandardSqmTranslatorFactory;
import org.hibernate.query.sqm.tree.select.SqmSelectStatement;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.sql.ast.SqlAstNodeRenderingMode;
import org.hibernate.sql.ast.SqlAstTranslator;
import org.hibernate.sql.ast.SqlAstTranslatorFactory;
import org.hibernate.sql.ast.spi.SqlAppender;
Expand All @@ -71,7 +73,10 @@
import org.hibernate.tool.schema.extract.spi.SequenceInformationExtractor;
import org.hibernate.tool.schema.internal.StandardForeignKeyExporter;
import org.hibernate.tool.schema.spi.Exporter;
import org.hibernate.type.JavaObjectType;
import org.hibernate.type.StandardBasicTypes;
import org.hibernate.type.descriptor.jdbc.ClobJdbcType;
import org.hibernate.type.descriptor.jdbc.ObjectNullAsBinaryTypeJdbcType;
import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry;
import org.hibernate.type.descriptor.sql.DdlType;
import org.hibernate.type.descriptor.sql.internal.CapacityDependentDdlType;
Expand All @@ -82,6 +87,7 @@
import jakarta.persistence.TemporalType;

import static org.hibernate.exception.spi.TemplatedViolatedConstraintNameExtractor.extractUsingTemplate;
import static org.hibernate.query.sqm.produce.function.FunctionParameterType.STRING;
import static org.hibernate.type.SqlTypes.BIGINT;
import static org.hibernate.type.SqlTypes.BINARY;
import static org.hibernate.type.SqlTypes.FLOAT;
Expand Down Expand Up @@ -276,10 +282,10 @@ public void initializeFunctionRegistry(FunctionContributions functionContributio
super.initializeFunctionRegistry(functionContributions);

CommonFunctionFactory functionFactory = new CommonFunctionFactory(functionContributions);
functionFactory.aggregates( this, SqlAstNodeRenderingMode.NO_PLAIN_PARAMETER );
functionFactory.instr();
functionFactory.substr();
functionFactory.substring_substr();
//also natively supports ANSI-style substring()
functionFactory.substringFromFor();
functionFactory.trunc();
functionFactory.trim2();
functionFactory.space();
Expand All @@ -302,12 +308,30 @@ public void initializeFunctionRegistry(FunctionContributions functionContributio
functionFactory.monthsBetween();
functionFactory.stddev();
functionFactory.variance();
functionFactory.locate_positionSubstring();
functionFactory.bitLength_pattern( "length(?1)*8" );

if ( getVersion().isSameOrAfter( 12 ) ) {
functionFactory.locate_charindex();
}

//coalesce() and nullif() both supported since Informix 12

functionContributions.getFunctionRegistry().register( "least", new CaseLeastGreatestEmulation( true ) );
functionContributions.getFunctionRegistry().register( "greatest", new CaseLeastGreatestEmulation( false ) );
functionContributions.getFunctionRegistry().namedDescriptorBuilder( "matches" )
.setInvariantType( functionContributions.getTypeConfiguration()
.getBasicTypeRegistry()
.resolve( StandardBasicTypes.STRING )
)
.setExactArgumentCount( 2 )
.setArgumentTypeResolver(
StandardFunctionArgumentTypeResolvers.impliedOrInvariant(
functionContributions.getTypeConfiguration(),
STRING
)
)
.setArgumentListSignature( "(STRING string, STRING pattern)" )
.register();
if ( supportsWindowFunctions() ) {
functionFactory.windowFunctions();
}
Expand Down Expand Up @@ -672,6 +696,11 @@ public String currentDate() {
return "today";
}

@Override
public String currentTime() {
return currentTimestamp();
}

@Override
public String currentTimestamp() {
return "current";
Expand Down Expand Up @@ -816,6 +845,17 @@ public void contributeTypes(TypeContributions typeContributions, ServiceRegistry
final JdbcTypeRegistry jdbcTypeRegistry = typeContributions.getTypeConfiguration().getJdbcTypeRegistry();
jdbcTypeRegistry.addDescriptor( Types.NCLOB, ClobJdbcType.DEFAULT );
typeContributions.contributeJdbcType( VarcharUUIDJdbcType.INSTANCE );
typeContributions.contributeJdbcType( ObjectNullAsBinaryTypeJdbcType.INSTANCE );

// Until we remove StandardBasicTypes, we have to keep this
typeContributions.contributeType(
new JavaObjectType(
ObjectNullAsBinaryTypeJdbcType.INSTANCE,
typeContributions.getTypeConfiguration()
.getJavaTypeRegistry()
.getDescriptor( Object.class )
)
);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,23 @@ public void testCurrentTimestamp(SessionFactoryScope scope) {
);
}

@Test
@TestForIssue(jiraKey = "HHH-18369")
public void testMatches(SessionFactoryScope scope) {
scope.inTransaction(
(session) -> {
String country = (String) session.createQuery(
"select e.country " +
"from Event e " +
"where e.id = :id and matches(e.country, :country) = 'T'" )
.setParameter( "id", event.id )
.setParameter( "country", "R*" )
.getSingleResult();
assertEquals( "Romania", country );
}
);
}

private Calendar todayCalendar() {
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.HOUR_OF_DAY, 0);
Expand Down
Loading