0 Replies Latest reply on Sep 17, 2007 7:20 PM by Frank Langelage

    QuerySyntaxException

    Frank Langelage Master

      On the way migrating a EJB 2.1 App to EJB 3.0 I got a problem with an EJB-QL query:
      SELECT OBJECT(k)
      FROM MbiFesta AS k, IN( k.mbiFekvw ) AS v
      WHERE k.tstNr = ?1 AND k.varId = ?2
      AND v.verwTabelle = 1 AND v.afCompNr = ?3 AND v.afLfdNr = ?4 AND v.afPosNr = ?5

      As a result I get:
      javax.ejb.EJBException: java.lang.IllegalArgumentException: org.hibernate.hql.ast.QuerySyntaxException: unexpected token: v near lin
      e 1, column 80 [SELECT k FROM biz.mbisoftware.fn.ejb.entity.MbiFesta AS k, IN( k.mbiFekvw ) AS v WHERE k.tstNr = ?1 AND k.varId = ?2
      AND v.verwTabelle = 1 AND v.afCompNr = ?3 AND v.afLfdNr = ?4 AND v.afPosNr = ?5]

      Why is this not legal?
      I also tried JOIN instead of IN, but got a similar exception: (unexpected token JOIN):
      FROM MbiFesta AS k, JOIN k.mbiFekvw AS v

      After spending much time to test different versions the following version works:
      SELECT DISTINCT k
      FROM MbiFesta AS k, MbiFekvw AS v
      WHERE k.festaSerial = v.festaSerial
      AND k.tstNr = ?1 AND k.varId = ?2
      AND v.verwTabelle = 1 AND v.afCompNr = ?3 AND v.afLfdNr = ?4 AND v.afPosNr = ?5

      But I'd like to understand why before searching and modifying other queries.