1 Reply Latest reply on Jul 9, 2002 12:57 PM by Dain Sundstrom

    Using the primary key of an EJB in one finder method

    Rafael Muñoz Newbie

      Hi all

      I have a problem making a finder method for a CMP Entity Bean.
      The primary key of the EJB is a single field called 'sid'.

      I have to do, for work, a finder that looks at by the field 'sid'
      and by the field 'version'.

      The problem is that, when i use the expression 'WHERE p.sid = ?1'
      the JBoss server gives me an error like:

      Was expecting one of:
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCEJBQLQuery.(JDBCEJBQLQuery.java:46)

      I suposs that i can't use the primary key in the way i try.
      Can anybody tell me about the way to do the finder method i want.
      At this moment my EJB QL code is:

      SELECT OBJECT(p) FROM PruebaVersion AS p WHERE p=?1 AND p.version=?2

      of course, that does´nt work.

        • 1. Re: Using the primary key of an EJB in one finder method
          Dain Sundstrom Master

          I'm not sure what your problem is. An importat part of that stack trace is the part where it tells you what it found that it couldn't match. Another important piece of informatnion is the type of the parameter.

          You can compare an entity to an entity valued parameter. You can compare a field to a parameter of the same type, with one exception. In EJB-QL, you are not allowed to compare dependent value classes (any class other then the simple primitive wrappers, dates, and entities); this restriction has been removed in JBossQL