Skip to content

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: [e6f5c1e, 27e72ac, 0e517d9, f859b93, fb08af3, 8a8354a, 894124a, dfdfbcb, 8658705, fe8b24d, 197ee03]

› 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
@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 );

Copy link
Author

Choose a reason for hiding this comment

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

I've tried using 'renderFetchPlusOffsetExpressionAsSingleParameter()'. But it doesn't work as expected, that's why I ended using the 'AsLiteral' version.

Let me explain...

It seems like if I use:
'renderFetchPlusOffsetExpressionAsSingleParameter(
Expression fetchClauseExpression,
Expression offsetClauseExpression,
int offset
)'

The third parameter 'int offset' which is set to '-1' is not being added to the calculation. The end resultSet has 'rowsLimit +1 row'.

But If I use 'renderFetchPlusOffsetExpressionAsLiteral()' with the 'int offset=-1' my end resultSet has exactly the 'rowsLimit' size. Which is what we want.

Copy link
Member

Choose a reason for hiding this comment

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

Looking at the implementation of AbstractSqlAstTranslator#renderFetchPlusOffsetExpressionAsSingleParameter, it should work. It might be the case that a fix that I did for HHH-19632 needs to be backported to ORM 6.6 to make this work fully. Can you please share how you were testing/verifying this?

Copy link
Author

Choose a reason for hiding this comment

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

I see, we are testing it like:

      session.beginTransaction();
      int rowOffset    = 27;
      int maxRowsLimit = 93;

      List<Book> books = session.createQuery("FROM Book ORDER BY id", Book.class)
        .setFirstResult(rowOffset)   // Offset
        .setMaxResults(maxRowsLimit) // Limit
        .list();

      // Check max rows limit
      Assertions.assertEquals( maxRowsLimit, books.size() );

And this fails with:
[ERROR] TestLimitHandler.testPaginationQueryOffsetAndLimit:136 expected: <93> but was: <94>

Note: the table contains 300 rows we expected to have 93 books (MaxRowsLimit)

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.

@carlblan carlblan force-pushed the timesten_dialect_updates branch from a526f53 to 4cc3ccf Compare August 8, 2025 21:48
@carlblan carlblan requested a review from beikov September 2, 2025 15:14
@carlblan
Copy link
Author

Hi @beikov , Could you help with a new review for this PR.

Thank you in advance.

@beikov
Copy link
Member

beikov commented Sep 23, 2025

Hi @beikov , Could you help with a new review for this PR.

Thank you in advance.

Hi, there are still a few comments that I made which you did not address. When that is done, I can give it another look.

@carlblan carlblan force-pushed the timesten_dialect_updates branch from 4cc3ccf to 8839486 Compare September 23, 2025 19:33
@carlblan
Copy link
Author

Hi @beikov I just updated the PR.
For the remaining comments I added an explanation on why those are still not addressed.
Could you help me reading/checking those comments I made?

Thank you in advance.

@beikov
Copy link
Member

beikov commented Sep 24, 2025

I don't see any comments or changes that address the my comments @carlblan, so maybe you forgot to press send on them? Or forgot to push the correct changes?

Copy link
Author

@carlblan carlblan left a comment

Choose a reason for hiding this comment

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

Hi @beikov,
I addressed most of the comments, but for the remaining ones (4) I added an explanation as a reply for each comment.

And again, thanks for your time helping with the review.

Kind regards

try {
if ( fetchClauseExpression != null ) {
// We need to substract 1 row to fit maxRows
renderFetchPlusOffsetExpressionAsLiteral( fetchClauseExpression, offsetClauseExpression, -1 );
Copy link
Author

Choose a reason for hiding this comment

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

I've tried using 'renderFetchPlusOffsetExpressionAsSingleParameter()'. But it doesn't work as expected, that's why I ended using the 'AsLiteral' version.

Let me explain...

It seems like if I use:
'renderFetchPlusOffsetExpressionAsSingleParameter(
Expression fetchClauseExpression,
Expression offsetClauseExpression,
int offset
)'

The third parameter 'int offset' which is set to '-1' is not being added to the calculation. The end resultSet has 'rowsLimit +1 row'.

But If I use 'renderFetchPlusOffsetExpressionAsLiteral()' with the 'int offset=-1' my end resultSet has exactly the 'rowsLimit' size. Which is what we want.

@carlblan carlblan force-pushed the timesten_dialect_updates branch from 48b9da2 to 197ee03 Compare October 3, 2025 19:25
Copy link
Author

@carlblan carlblan left a comment

Choose a reason for hiding this comment

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

Changes:

  • Addressing latest comments in initializeFunctionRegistry() : For 'getdate', 'trunc' and 'round'
  • Answering question regarding the use of renderFetchPlusOffsetExpressionAsSingleParameter()

Let me know if anything.
Thanks.

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

Successfully merging this pull request may close these issues.

2 participants