-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
base: 6.6
Are you sure you want to change the base?
Conversation
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 › This message was automatically generated. |
Here's a new PR to update the TimesTen Community Dialect for Hibernate 6.6 I closed the previous PR: #10273 This is a clean PR with the same changes but addressed the previous comments:
Let me know any other comment. Thanks |
hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/TimesTenDialect.java
Outdated
Show resolved
Hide resolved
hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/TimesTenDialect.java
Outdated
Show resolved
Hide resolved
...mmunity-dialects/src/main/java/org/hibernate/community/dialect/TimesTenSqlAstTranslator.java
Outdated
Show resolved
Hide resolved
...mmunity-dialects/src/main/java/org/hibernate/community/dialect/TimesTenSqlAstTranslator.java
Outdated
Show resolved
Hide resolved
@@ -143,4 +145,56 @@ protected boolean supportsRowValueConstructorSyntaxInInList() { | |||
protected boolean supportsRowValueConstructorSyntaxInQuantifiedPredicates() { | |||
return false; | |||
} | |||
|
|||
@Override |
There was a problem hiding this comment.
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
?
hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/TimesTenDialect.java
Outdated
Show resolved
Hide resolved
hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/TimesTenDialect.java
Outdated
Show resolved
Hide resolved
…LimitHandler and TimesTenSequenceSupport
…ate contributor. Also addressing some comments from the PR
7a81939
to
a526f53
Compare
try { | ||
if ( fetchClauseExpression != null ) { | ||
// We need to substract 1 row to fit maxRows | ||
renderFetchPlusOffsetExpressionAsLiteral( fetchClauseExpression, offsetClauseExpression, -1 ); |
There was a problem hiding this comment.
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?
renderFetchPlusOffsetExpressionAsLiteral( fetchClauseExpression, offsetClauseExpression, -1 ); | |
renderFetchPlusOffsetExpressionAsSingleParameter( fetchClauseExpression, offsetClauseExpression, -1 ); |
functionContributions.getFunctionRegistry().register( | ||
"rtrim", new StandardSQLFunction("rtrim", StandardBasicTypes.STRING) | ||
); | ||
functionContributions.getFunctionRegistry().register( | ||
"ltrim", new StandardSQLFunction("ltrim", StandardBasicTypes.STRING) | ||
); |
There was a problem hiding this comment.
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?
functionContributions.getFunctionRegistry().register( | |
"rtrim", new StandardSQLFunction("rtrim", StandardBasicTypes.STRING) | |
); | |
functionContributions.getFunctionRegistry().register( | |
"ltrim", new StandardSQLFunction("ltrim", StandardBasicTypes.STRING) | |
); | |
functionFactory.trim2(); |
functionContributions.getFunctionRegistry().register( | ||
"length", new StandardSQLFunction("length", StandardBasicTypes.LONG) | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
functionContributions.getFunctionRegistry().register( | |
"length", new StandardSQLFunction("length", StandardBasicTypes.LONG) | |
); | |
functionFactory.characterLength_length( SqlAstNodeRenderingMode.DEFAULT ); |
functionContributions.getFunctionRegistry().register( | ||
"to_char", new StandardSQLFunction("to_char", StandardBasicTypes.STRING) | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
functionContributions.getFunctionRegistry().register( | |
"to_char", new StandardSQLFunction("to_char", StandardBasicTypes.STRING) | |
); | |
functionFactory.toCharNumberDateTimestamp(); |
functionContributions.getFunctionRegistry().register( | ||
"str", new StandardSQLFunction("to_char", StandardBasicTypes.STRING) | ||
); |
There was a problem hiding this comment.
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.
functionContributions.getFunctionRegistry().register( | |
"str", new StandardSQLFunction("to_char", StandardBasicTypes.STRING) | |
); |
functionContributions.getFunctionRegistry().register( | ||
"substring", new StandardSQLFunction( "substr", StandardBasicTypes.STRING ) | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
functionContributions.getFunctionRegistry().register( | |
"substring", new StandardSQLFunction( "substr", StandardBasicTypes.STRING ) | |
); | |
functionFactory.substring_substr(); |
functionContributions.getFunctionRegistry().register( | ||
"to_date", new StandardSQLFunction("to_date", StandardBasicTypes.TIMESTAMP) | ||
); |
There was a problem hiding this comment.
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
functionContributions.getFunctionRegistry().register( | |
"to_date", new StandardSQLFunction("to_date", StandardBasicTypes.TIMESTAMP) | |
); |
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) | ||
); |
There was a problem hiding this comment.
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.
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) | |
); |
functionContributions.getFunctionRegistry().register( | ||
"to_timestamp", new StandardSQLFunction("to_timestamp", StandardBasicTypes.TIMESTAMP) | ||
); |
There was a problem hiding this comment.
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
functionContributions.getFunctionRegistry().register( | |
"to_timestamp", new StandardSQLFunction("to_timestamp", StandardBasicTypes.TIMESTAMP) | |
); |
public String currentTime() { | ||
return "sysdate"; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Override | |
public String currentTimestamp() { | |
return "sysdate"; | |
} |
"sysdate", new CurrentFunction("sysdate", "sysdate", timestampType) | ||
); | ||
functionContributions.getFunctionRegistry().register( | ||
"getdate", new StandardSQLFunction("getdate", StandardBasicTypes.TIMESTAMP) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"getdate", new StandardSQLFunction("getdate", StandardBasicTypes.TIMESTAMP) | |
"getdate", new CurrentFunction( "getdate", "getdate", timestampType ) |
functionContributions.getFunctionRegistry().register( | ||
"add_months", new StandardSQLFunction("add_months", StandardBasicTypes.DATE) | ||
); | ||
functionContributions.getFunctionRegistry().register( | ||
"months_between", new StandardSQLFunction("months_between", StandardBasicTypes.FLOAT) | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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(); |
functionContributions.getFunctionRegistry().register( | ||
"trunc", new StandardSQLFunction("trunc") | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
functionContributions.getFunctionRegistry().register( | |
"trunc", new StandardSQLFunction("trunc") | |
); | |
functionContributions.getFunctionRegistry().register( | |
"trunc", | |
new OracleTruncFunction( functionContributions.getTypeConfiguration() ) | |
); | |
functionContributions.getFunctionRegistry().registerAlternateKey( "truncate", "trunc" ); |
functionContributions.getFunctionRegistry().register( | ||
"round", new StandardSQLFunction("round") | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
functionContributions.getFunctionRegistry().register( | |
"round", new StandardSQLFunction("round") | |
); | |
functionFactory.round(); |
functionContributions.getFunctionRegistry().register( | ||
"bitnot", new StandardSQLFunction("bitnot", StandardBasicTypes.INTEGER) | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
functionContributions.getFunctionRegistry().register( | |
"bitnot", new StandardSQLFunction("bitnot", StandardBasicTypes.INTEGER) | |
); | |
functionFactory.round(); |
functionContributions.getFunctionRegistry().register( | ||
"nvl", new StandardSQLFunction("nvl") | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
functionContributions.getFunctionRegistry().register( | |
"nvl", new StandardSQLFunction("nvl") | |
); | |
functionRegistry.namedDescriptorBuilder( "nvl" ) | |
.setMinArgumentCount( 2 ) | |
.setArgumentTypeResolver( StandardFunctionArgumentTypeResolvers.ARGUMENT_OR_IMPLIED_RESULT_TYPE ) | |
.setReturnTypeResolver( StandardFunctionReturnTypeResolvers.useFirstNonNull() ) | |
.register(); | |
); |
There was a problem hiding this 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.
Some updates from an Oracle employee to the Oracle TimesTen Community dialect. ( Hibernate 6.6 )
In TimesTenDialect.java
In TimesTenSqlAstTranslator.java
In TimesTenLimitHandler.java
In TimesTenSequenceSupport.java
Testing:
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.