5 Replies Latest reply on May 28, 2005 6:33 PM by robr

    Cannot use < or > symbol in ejb-ql

    robr

      I am trying to create some finders for an Entity bean.

      One of my finders has the following signatures in the home file.

      UsersEntity findUsernameEquals(String key) throws RemoteException, FinderException;
      


      The query part of my ejb-jar.xml file is as follows.
       <query>
       <description>
       Returns Entity Bean that has Username
       </description>
       <query-method>
       <method-name>findUsernameEquals</method-name>
       <method-params>
       <method-param>java.lang.String</method-param>
       </method-params>
       </query-method>
       <ejb-ql>
       select object(u) FROM UsersEntityEJB u where u.username < ?1
       </ejb-ql>
       </query>
      


      Any time I try to use < or <> in the <ejb-ql> query string I get the following error.

      The content of elements must consist of well-formed character data or markup.
      


      I am pretty sure the problem is that the parser that parses the xml is thinking the the < character marks the beginning of the next tag. I am trying to use it in the ejb-ql statement. Is there some trick to get this to work such a putting some character in front of the < so that the parser knows to not treat it as the beginning of the next tag?

        • 1. Re: Cannot use < or > symbol in ejb-ql
          aloubyansky

           

          <ejb-ql>
          <![CDATA[select object(u) FROM UsersEntityEJB u where u.username < ?1]]></ejb-ql>


          • 2. Re: Cannot use < or > symbol in ejb-ql
            robr

            Thanks a million for the reply Alex. I really appreciatte it. I haven't tried it yet but I assume from your post that you know exactly what you're talking about.

            • 3. Re: Cannot use < or > symbol in ejb-ql
              robr

              I just tried the suggestion. Here is my code.




              Returns Entity Bean that has Username

              <query-method>
              <method-name>findUsernameEquals</method-name>
              <method-params>
              <method-param>java.lang.String</method-param>
              </method-params>
              </query-method>
              <ejb-ql>
              <![CDATA[select object(u) FROM UsersEntityEJB u where u.username < ?1]]>
              </ejb-ql>



              My editor (intelliJ) has a red mark by and <ejb-ql>. If I put my cursor on the red mark it gives an error message that says the Element is not closed.

              Could you give me a little more help Alex? I will look at the DTD definition to see if I can figure it out. Thanks.

              • 4. Re: Cannot use < or > symbol in ejb-ql
                robr

                My first reply get messed up so here it is again.

                I just tried the suggestion. Here is my code.

                 <query>
                 <description>
                 Returns Entity Bean that has Username
                 </description>
                 <query-method>
                 <method-name>findUsernameEquals</method-name>
                 <method-params>
                 <method-param>java.lang.String</method-param>
                 </method-params>
                 </query-method>
                 <ejb-ql>
                 <![CDATA[select object(u) FROM UsersEntityEJB u where u.username < ?1]]>
                 </ejb-ql>
                 </query>
                


                My editor (intelliJ) has a red mark by and <ejb-ql>. If I put my cursor on the red mark it gives an error message that says the Element is not closed.

                Could you give me a little more help Alex? I will look at the DTD definition to see if I can figure it out. Thanks.

                • 5. Re: Cannot use < or > symbol in ejb-ql
                  robr

                  Never mind. Must be a qwirk in the Intellij IDE. I typed the code in as you suggested, which created the red error marks, copied the code, deleted the code and then pasted it back in. The red marks went away after the past and my application ran fine when I started JBOSS.

                  Thanks again.