mysql - Not able to use two selects in HQL -
using hibernate , query language. seek execute below query in pojo
string sql = "select (select count(*) info v " + insuranceid +" in (v.insuranceid1.id, v.insuranceid2.id, v.insuranceid3.id))" +" + (select count(*) sat s " + insuranceid +" in (s.insuranceid1.id, s.insuranceid2.id, s.insuranceid3.id))";
em.createquery(sql, long.class).getsingleresult();
i next error
2:27:47,128 error [stderr] (http-/0.0.0.0:8080-5) java.lang.illegalargumentexception: org.hibernate.hql.internal.ast.querysyntaxexception: unexpected end of subtree [select (select count(*) info v 991 in (v.insuranceid1.id, v.insuranceid2.id, v.insuranceid3.id)) + (select count(*) slot s 991 in (s.insuranceid1.id, s.insuranceid2.id, s.insuranceid3.id))]
please advice
try createnativequery
object l = em.createnativequery(sql).getsingleresult();
it should homecoming integer containing sum of counts.
i suppose hql doesn't back upwards select without clause.
mysql hibernate hql hibernate-mapping
No comments:
Post a Comment