I am getting following error using hibernate
java.sql.SQLSyntaxErrorException: ORA-01795: maximum number of expressions in a list is 1000
I am using following code
private List<Dependency> getDependencies(QuestionnaireTemplate questionnaireTemplate) {
CustomSearchCriteria dependCriteria = new CustomSearchCriteria(Dependency.class)
def dependProj = ['id']
dependProj.each { item ->
dependCriteria.projections.add(new CustomProjection(item))
}
dependCriteria.expressions.add
(new CustomExpression('dependencyToReqVals.requirementValue.requirement.section.template.id', questionnaireTemplate.id, "="))
def depensWithId = searchByCriteria(dependCriteria)
List<Dependency> result = []
if (depensWithId) {
def criteria = Dependency.createCriteria()
result = criteria.listDistinct {
'in'('id', depensWithId.collect{it.id})
fetchMode('dependencyToReqVals', FetchMode.JOIN)
}
}
result
}
The dependency list is more than 1000. How do i handle this in above code
The query that is generated is as follows. The subquery returns more than 1000 values
select
this_.TABLEQSDE_ID as TABLEQSDE1_91_1_,
this_.version as version91_1_,
this_.CREATED_BY as CREATED3_91_1_,
this_.CREATION_DATE as CREATION4_91_1_,
this_.LAST_UPD_DATE as LAST5_91_1_,
this_.UPDATED_BY as UPDATED6_91_1_,
this_.LOGICAL_STRUCTURE as LOGICAL7_91_1_,
this_.memo as memo91_1_,
this_.NAME as NAME91_1_,
dependency2_.TABLEQSDE_ID as TABLEQSDE7_3_,
dependency2_.TABLEQSDR_ID as TABLEQSDR1_3_,
dependency2_.TABLEQSDR_ID as TABLEQSDR1_95_0_,
dependency2_.version as version95_0_,
dependency2_.CREATED_BY as CREATED3_95_0_,
dependency2_.CREATION_DATE as CREATION4_95_0_,
dependency2_.LAST_UPD_DATE as LAST5_95_0_,
dependency2_.UPDATED_BY as UPDATED6_95_0_,
dependency2_.TABLEQSDE_ID as TABLEQSDE7_95_0_,
dependency2_.TABLEQSRV_ID as TABLEQSRV8_95_0_,
dependency2_.TYPE as TYPE95_0_
from
TABLE_QST_SETUP_DEPENDENCY this_
left outer join
TABLE_QST_SETUP_DEP_TO_REQ_VAL dependency2_
on this_.TABLEQSDE_ID=dependency2_.TABLEQSDE_ID
where
this_.TABLEQSDE_ID in
(select
this_.TABLEQSDE_ID as y0_
from
TABLE_QST_SETUP_DEPENDENCY this_
left outer join
TABLE_QST_SETUP_DEP_TO_REQ_VAL dependency1_
on this_.TABLEQSDE_ID=dependency1_.TABLEQSDE_ID
left outer join
TABLE_QST_SETUP_REQ_VALUE requiremen2_
on dependency1_.TABLEQSRV_ID=requiremen2_.TABLEQSRV_ID
left outer join
TABLE_QST_SETUP_REQUIREMENT requiremen3_
on requiremen2_.REQUIREMENT_TABLEQSRE_ID=requiremen3_.TABLEQSRE_ID
left outer join
TABLE_QST_SETUP_SECTION section3x4_
on requiremen3_.TABLEQSSC_ID=section3x4_.TABLEQSSC_ID
left outer join
TABLE_QST_SETUP_TEMPLATE template4x5_
on section3x4_.TABLEQSTE_ID=template4x5_.TABLEQSTE_ID
where
template4x5_.TABLEQSTE_ID=789053796430);