1 Reply Latest reply on Sep 9, 2004 9:20 AM by Gerd Streubel

    EJB QL Underscore in column name

    annapurna Newbie

      I have column names with underscores( USER_ID ) in my database. When I tried to write a CMP2 bean for this table in the primarykey query I have

      SELECT object(a) FROM user a where a.us_userid

      While deploying I am getting an error saying
      Unknown terminal field: at line 1, column 39. Encountered: "us" after: "a."

      Can someone please tell me how can I get rid of this. Is there anything I have to do before the "_" to make the column read as one complete string. Since "_" is a wild character in EJBQL I guess an error is generated here.


      Any help is greatly appreciated.

      Thanks,
      Anna.

        • 1. Re: EJB QL Underscore in column name
          Gerd Streubel Newbie

          The names used in EJB QL are the ones that you define as getter an setter for the specified column. The mapping between the getter/setter and the column name is done in the ejb-DD ejb-jar.xml.

          Using XDoclet it might be:

          /**
          * @ejb:persistence column-name = "USER_ID"
          * @ejb:interface-method view-type="local"
          */
          public abstract Long getUserId();
          /**
          * @ejb:interface-method view-type="local"
          */
          public abstract void setUserId(Long userId);


          Then the EJB QL looks like:
          SELECT object(a) FROM user a where a.userId = ...