Adrodoc (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=5b2a4a0...
) *created* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiOGJhNmIyODRi...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-16589?atlOrigin=eyJpIjoiOGJhNm...
) HHH-16589 (
https://hibernate.atlassian.net/browse/HHH-16589?atlOrigin=eyJpIjoiOGJhNm...
) In-Clause Parameter Padding mistreats Dilect.getInExpressionCountLimit which can cause
ORA-01795: maximum number of expressions in a list is 1000 (
https://hibernate.atlassian.net/browse/HHH-16589?atlOrigin=eyJpIjoiOGJhNm...
)
Issue Type: Bug Affects Versions: 6.2.1, 6.2.2 Assignee: Unassigned Created: 11/May/2023
04:55 AM Priority: Major Reporter: Adrodoc (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=5b2a4a0...
)
If you enable hibernate.query.in_clause_parameter_padding in {{persistence.xml}}and then
execute the following query with 1900 parameters:
select m from MyEntity m where m.id in ?1
You will get this error ORA-01795: maximum number of expressions in a list is 1000.
The issue lies in AbstractSqlAstTranslator : if there are more listExpressions than
inExprLimit and inClauseParameterPaddingEnabled is true then bindValueMaxCount is
calculated as ceilingPowerOfTwo( bindValueCount % inExprLimit ). In our example this is
ceilingPowerOfTwo(1900 % 1000) == 1024.
This result is then used to pad the last in clause without checking inExprLimit again:
https://github.com/hibernate/hibernate-orm/blob/6746c30275b6600622d82613d...
if ( inClauseParameterPaddingEnabled ) {
final Expression lastExpression = itemAccessor.apply( listExpressions.get(
listExpressions.size() - 1 ) );
for ( ; `; itemNumber++ ) {
appendSql( separator );
lastExpression.accept( this );
separator = COMA_SEPARATOR;
}
}
A simple fix would be to change the condition of this for-loop to itemNumber <
Math.min(bindValueMaxCount, inExprLimit) , but I feel like the whole calculation could be
simplified.
(
https://hibernate.atlassian.net/browse/HHH-16589#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-16589#add-comment?atlOrigin=ey...
)
Get Jira notifications on your phone! Download the Jira Cloud app for Android (
https://play.google.com/store/apps/details?id=com.atlassian.android.jira....
) or iOS (
https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=Em...
) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100225- sha1:84d3b45 )