Skip to content

Oracle TimesTen Dialect for Hibernate 6.6 Updates #10492

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: 6.6
Choose a base branch
from

Conversation

carlblan
Copy link

@carlblan carlblan commented Jul 8, 2025

Some updates from an Oracle employee to the Oracle TimesTen Community dialect. ( Hibernate 6.6 )

In TimesTenDialect.java

Adding more datatypes into columnType()
Added more SQL functions support into initializeFunctionRegistry()
Updated the custom definition for 'getForUpdateString()'
Added a custom definition for 'getNativeIdentifierGeneratorStrategy()'
Added a custom definition for 'currentDate()'
Added a custom definition for 'currentTime()'
Added a custom definition for 'getMaxVarcharLength()'
Added a custom definition for 'getMaxVarbinaryLength()'
Added a custom definition for 'isEmptyStringTreatedAsNull()'
Added a custom definition for 'supportsTupleDistinctCounts()'
Added a custom definition for 'getDual()'
Added a custom definition for 'getFromDualForSelectOnly()'

In TimesTenSqlAstTranslator.java

Added a custom definition for 'renderRowsToClause()'

In TimesTenLimitHandler.java

    The class now extends 'AbstractLimitHandler'
    Removed a custom definition for 'insert()'
    Added a custom definition for 'supportsLimit()'
    Added a custom definition for 'supportsOffset()'
    Added a custom definition for 'supportsLimitOffset()'
    Added a custom definition for 'supportsVariableLimit()'
    Added a custom definition for 'convertToFirstRowValue(int zeroBasedFirstResult)'
    Added a custom definition for 'useMaxForLimit()'
    Added a custom definition for 'limitClause(boolean hasFirstRow)'

In TimesTenSequenceSupport.java

    The Class now implements 'SequenceSupport'
    Added a custom definition for 'supportsSequences()'
    Added a custom definition for 'supportsPooledSequences()'
    Added a custom definition for 'getSelectSequenceNextValString(String sequenceName)'
    Added a custom definition for 'getSequenceNextValString(String sequenceName)'
    Added a custom definition for 'getCreateSequenceString(String sequenceName)'
    Added a custom definition for 'getDropSequenceString(String sequenceName)'

Testing:

The changes were tested with some local tests we have using this Hibernate 6 TimesTen community dialect.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license
and can be relicensed under the terms of the LGPL v2.1 license in the future at the maintainers' discretion.
For more information on licensing, please check here.


@hibernate-github-bot
Copy link

hibernate-github-bot bot commented Jul 8, 2025

Thanks for your pull request!

This pull request does not follow the contribution rules. Could you have a look?

❌ All commit messages should start with a JIRA issue key matching pattern HHH-\d+
    ↳ Offending commits: [7477aef, 67cbf58, 6ba01b1, 4502461, 976686f, 8613200, a526f53]

› This message was automatically generated.

@carlblan
Copy link
Author

carlblan commented Jul 8, 2025

@beikov @mbellade @yrodiere

Here's a new PR to update the TimesTen Community Dialect for Hibernate 6.6

I closed the previous PR: #10273
Since I accidentally fetched/updated from main instead of 6.6 branch

This is a clean PR with the same changes but addressed the previous comments:

  • Removed the copyright headers from my changes since Oracle has been added as a corporate contributor.
  • Addressed comments for 'initializeFunctionRegistry()'

Let me know any other comment.

Thanks

@carlblan carlblan changed the title Oracle TimesTen 6.6 Dialect Updates Oracle TimesTen Dialect for Hibernate 6.6 Updates Jul 8, 2025
@@ -143,4 +145,56 @@ protected boolean supportsRowValueConstructorSyntaxInInList() {
protected boolean supportsRowValueConstructorSyntaxInQuantifiedPredicates() {
return false;
}

@Override
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this function is only used in TimesTen, could you please remove it from AbstractSqlAstTranslator?

@carlblan carlblan force-pushed the timesten_dialect_updates branch from 7a81939 to a526f53 Compare July 28, 2025 21:55
try {
if ( fetchClauseExpression != null ) {
// We need to substract 1 row to fit maxRows
renderFetchPlusOffsetExpressionAsLiteral( fetchClauseExpression, offsetClauseExpression, -1 );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does TimesTen not support a parameter here?

Suggested change
renderFetchPlusOffsetExpressionAsLiteral( fetchClauseExpression, offsetClauseExpression, -1 );
renderFetchPlusOffsetExpressionAsSingleParameter( fetchClauseExpression, offsetClauseExpression, -1 );

Comment on lines +191 to +196
functionContributions.getFunctionRegistry().register(
"rtrim", new StandardSQLFunction("rtrim", StandardBasicTypes.STRING)
);
functionContributions.getFunctionRegistry().register(
"ltrim", new StandardSQLFunction("ltrim", StandardBasicTypes.STRING)
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use the standard trim function definitions?

Suggested change
functionContributions.getFunctionRegistry().register(
"rtrim", new StandardSQLFunction("rtrim", StandardBasicTypes.STRING)
);
functionContributions.getFunctionRegistry().register(
"ltrim", new StandardSQLFunction("ltrim", StandardBasicTypes.STRING)
);
functionFactory.trim2();

Comment on lines +197 to +199
functionContributions.getFunctionRegistry().register(
"length", new StandardSQLFunction("length", StandardBasicTypes.LONG)
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
functionContributions.getFunctionRegistry().register(
"length", new StandardSQLFunction("length", StandardBasicTypes.LONG)
);
functionFactory.characterLength_length( SqlAstNodeRenderingMode.DEFAULT );

Comment on lines +201 to +203
functionContributions.getFunctionRegistry().register(
"to_char", new StandardSQLFunction("to_char", StandardBasicTypes.STRING)
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
functionContributions.getFunctionRegistry().register(
"to_char", new StandardSQLFunction("to_char", StandardBasicTypes.STRING)
);
functionFactory.toCharNumberDateTimestamp();

Comment on lines +207 to +209
functionContributions.getFunctionRegistry().register(
"str", new StandardSQLFunction("to_char", StandardBasicTypes.STRING)
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems this is already registered by Dialect.initializeFunctionRegistry to use the casting mechanism. It would be best to take a look at OracleDialect#castPattern and copy over what is compatible or makes sense.

Suggested change
functionContributions.getFunctionRegistry().register(
"str", new StandardSQLFunction("to_char", StandardBasicTypes.STRING)
);

Comment on lines +210 to +212
functionContributions.getFunctionRegistry().register(
"substring", new StandardSQLFunction( "substr", StandardBasicTypes.STRING )
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
functionContributions.getFunctionRegistry().register(
"substring", new StandardSQLFunction( "substr", StandardBasicTypes.STRING )
);
functionFactory.substring_substr();

Comment on lines +216 to +218
functionContributions.getFunctionRegistry().register(
"to_date", new StandardSQLFunction("to_date", StandardBasicTypes.TIMESTAMP)
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Already covered by functionFactory.toCharNumberDateTimestamp() above

Suggested change
functionContributions.getFunctionRegistry().register(
"to_date", new StandardSQLFunction("to_date", StandardBasicTypes.TIMESTAMP)
);

Comment on lines +226 to +234
functionContributions.getFunctionRegistry().register(
"current_date", new CurrentFunction("sysdate", "sysdate", dateType)
);
functionContributions.getFunctionRegistry().register(
"current_time", new CurrentFunction("sysdate", "sysdate", timeType)
);
functionContributions.getFunctionRegistry().register(
"current_timestamp", new CurrentFunction("sysdate", "sysdate", timestampType)
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Already covered by Dialect.initializeFunctionRegistry, which uses the currentTime, currentTimestamp and currentDate of this Dialect to determine the SQL fragment.

Suggested change
functionContributions.getFunctionRegistry().register(
"current_date", new CurrentFunction("sysdate", "sysdate", dateType)
);
functionContributions.getFunctionRegistry().register(
"current_time", new CurrentFunction("sysdate", "sysdate", timeType)
);
functionContributions.getFunctionRegistry().register(
"current_timestamp", new CurrentFunction("sysdate", "sysdate", timestampType)
);

Comment on lines +235 to +237
functionContributions.getFunctionRegistry().register(
"to_timestamp", new StandardSQLFunction("to_timestamp", StandardBasicTypes.TIMESTAMP)
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Already covered by functionFactory.toCharNumberDateTimestamp() above

Suggested change
functionContributions.getFunctionRegistry().register(
"to_timestamp", new StandardSQLFunction("to_timestamp", StandardBasicTypes.TIMESTAMP)
);

public String currentTime() {
return "sysdate";
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@Override
public String currentTimestamp() {
return "sysdate";
}

"sysdate", new CurrentFunction("sysdate", "sysdate", timestampType)
);
functionContributions.getFunctionRegistry().register(
"getdate", new StandardSQLFunction("getdate", StandardBasicTypes.TIMESTAMP)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"getdate", new StandardSQLFunction("getdate", StandardBasicTypes.TIMESTAMP)
"getdate", new CurrentFunction( "getdate", "getdate", timestampType )

Comment on lines +240 to +245
functionContributions.getFunctionRegistry().register(
"add_months", new StandardSQLFunction("add_months", StandardBasicTypes.DATE)
);
functionContributions.getFunctionRegistry().register(
"months_between", new StandardSQLFunction("months_between", StandardBasicTypes.FLOAT)
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
functionContributions.getFunctionRegistry().register(
"add_months", new StandardSQLFunction("add_months", StandardBasicTypes.DATE)
);
functionContributions.getFunctionRegistry().register(
"months_between", new StandardSQLFunction("months_between", StandardBasicTypes.FLOAT)
);
functionFactory.addMonths();
functionFactory.monthsBetween();

Comment on lines +253 to +255
functionContributions.getFunctionRegistry().register(
"trunc", new StandardSQLFunction("trunc")
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
functionContributions.getFunctionRegistry().register(
"trunc", new StandardSQLFunction("trunc")
);
functionContributions.getFunctionRegistry().register(
"trunc",
new OracleTruncFunction( functionContributions.getTypeConfiguration() )
);
functionContributions.getFunctionRegistry().registerAlternateKey( "truncate", "trunc" );

Comment on lines +256 to +258
functionContributions.getFunctionRegistry().register(
"round", new StandardSQLFunction("round")
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
functionContributions.getFunctionRegistry().register(
"round", new StandardSQLFunction("round")
);
functionFactory.round();

Comment on lines +261 to +263
functionContributions.getFunctionRegistry().register(
"bitnot", new StandardSQLFunction("bitnot", StandardBasicTypes.INTEGER)
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
functionContributions.getFunctionRegistry().register(
"bitnot", new StandardSQLFunction("bitnot", StandardBasicTypes.INTEGER)
);
functionFactory.round();

Comment on lines +280 to +282
functionContributions.getFunctionRegistry().register(
"nvl", new StandardSQLFunction("nvl")
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
functionContributions.getFunctionRegistry().register(
"nvl", new StandardSQLFunction("nvl")
);
functionRegistry.namedDescriptorBuilder( "nvl" )
.setMinArgumentCount( 2 )
.setArgumentTypeResolver( StandardFunctionArgumentTypeResolvers.ARGUMENT_OR_IMPLIED_RESULT_TYPE )
.setReturnTypeResolver( StandardFunctionReturnTypeResolvers.useFirstNonNull() )
.register();
);

Copy link
Member

@beikov beikov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please try to reuse the existing CommonFunctionFactory methods as much as possible, since they also contain parameter type inference information and other extras that you are missing right now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants