简体   繁体   中英

Hibernate : Caused by: java.sql.SQLException: Operand should contain 1 column(s)

Exception : Caused by: java.sql.SQLException: Operand should contain 1 column(s) Caused by: org.hibernate.exception.DataException: could not extract ResultSet

The HQL that i have written is as follows:

select sm from SystemMessage sm 
left join sm.systemMessageMaps smrm 
left join smrm.role r
left join smrm.projectGroup pg
left join smrm.assessmentVersion av 
left join smrm.severity sms
where ( (r.id is NULL) and (pg.id is NULL) and (av.id IN (:assesmentVersionID) ) 
         or(pg.code =:projectGroup and av.id IN (:assesmentVersionID) and  r.id is NULL) 
         or(r.name =:roleName AND av.id IN (:assesmentVersionID) and pg.id is NULL)
         or( r.name =:roleName and  pg.code =:projectGroup AND av.id IN (:assesmentVersionID) ) 
       ) and 
      ( ( sm.startDate is null or sm.startDate <= current_timestamp ) and ( sm.endDate is null or sm.endDate >= current_timestamp)) 
order by sms.priority,smrm.severityRank,sm.startDate

I happen to get this exception after i added in the in clause to the parameter:

av.id IN (:assesmentVersionID)

and i set the parameter value as

query.setParameterList("assesmentVersionID", assessmentVersionIDList);

i wonder where have i gone wrong!

Try removing the parenthesis:

select sm from SystemMessage sm 
left join sm.systemMessageMaps smrm 
left join smrm.role r
left join smrm.projectGroup pg
left join smrm.assessmentVersion av 
left join smrm.severity sms
where ( (r.id is NULL) and (pg.id is NULL) and av.id IN (:assesmentVersionID) 
         or(pg.code =:projectGroup and av.id IN (:assesmentVersionID) and  r.id is NULL) 
         or(r.name =:roleName AND av.id IN (:assesmentVersionID) and pg.id is NULL)
         or( r.name =:roleName and  pg.code =:projectGroup AND av.id IN (:assesmentVersionID) ) 
       ) and 
      ( ( sm.startDate is null or sm.startDate <= current_timestamp ) and ( sm.endDate is null or sm.endDate >= current_timestamp)) 
order by sms.priority,smrm.severityRank,sm.startDate

This should work, if not try removing the parenthesis from (:assesmentVersionID) too.

Let me know if it solves the issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM