0 Replies Latest reply on Dec 13, 2005 9:02 AM by Mircea Militaru

    Hibernate translates query wrong

    Mircea Militaru Newbie

      I think there is a bug in a query statement translated by hibernate. When running a query like this :
      SELECT COUNT(o) FROM org.ictrace.server.pm.DMWeightBean o WHERE ((o.sale.reference = :reference) OR (o.purchase.localReference = :reference1))

      This shows in the hibernate logs :

      2005-11-16 11:13:09,838 DEBUG [org.hibernate.hql.ast.QueryTranslatorImpl] HQL: SELECT COUNT(o) FROM org.ictrace.server.pm.DMWeightBean o WHERE ((o.sale.reference = :reference) OR (o.purchase.localReference = :reference1))
      2005-11-16 11:13:09,838 DEBUG [org.hibernate.hql.ast.QueryTranslatorImpl] SQL: select count(dmweightbe0_.UNID_UOID) as col_0_0_ from t_Weight dmweightbe0_, t_WeightGroup dmweightgr1_, t_WeightGroup dmweightgr2_ where dmweightbe0_.f_Purchase_UOID=dmweightgr2_.UNID_UOID and dmweightbe0_.f_Sale_UOID=dmweightgr1_.UNID_UOID and (dmweightgr1_.f_Reference=? or dmweightgr2_.f_LocalReference=?)

      This is wrong because there shouldn't be a "AND" UNID_UOID selections.

      We are using JBoss 4.0.2 RC1 with EJB3 if this helps.