3 Replies Latest reply on Feb 27, 2002 10:33 AM by pazu

    EJB-QL Problem in jboss-3.0.0beta

    pazu

      I've got a problem deploying some CMP entity beans into jboss 3.0 beta. Here is the problem:

      DEBUG [findAll] EQL-QL: SELECT OBJECT(a) FROM Agente a
      DEBUG [findAll] SQL: SELECT t1_a.AGENTE_ID FROM AGENTES t1_a
      DEBUG [findByLogin] EQL-QL: SELECT OBJECT(a) FROM Agente a WHERE a.login LIKE ?1ERROR [EntityContainer] Exception in service lifecyle operation: start
      org.jboss.deployment.DeploymentException: Unable to parse EJB-QL: SELECT OBJECT(a) FROM Agente a WHERE a.login LIKE ?1
       at org.jboss.ejb.plugins.cmp.jdbc.JDBCEJBQLQuery.<init>(JDBCEJBQLQuery.java:51)
       at org.jboss.ejb.plugins.cmp.jdbc.JDBCCommandFactory.createEJBQLQuery(JDBCCommandFactory.java:44)
       at org.jboss.ejb.plugins.cmp.jdbc.JDBCQueryManager.start(JDBCQueryManager.java:177)
       at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.start(JDBCStoreManager.java:335)
      


      The stack trace continues. I posted only while it's in org.jboss.ejb.plugins.cmp.jdbc package. Please note that the findAll() EJB-QL is correctly parsed, but the findByLogin(String login) gives an error. Just to make sure I'm not crazy. here is the portion from ejb-jar.xml regarding this bean and query.


      <entity>
       <ejb-name>Agente</ejb-name>
       (...)
       <cmp-field>
       <description>[[CDATA[]]</description>
       <field-name>login</field-name>
       </cmp-field>
       (...)
       <query>
       <query-method>
       <method-name>findByLogin</method-name>
       <methad-params>
       <method-param>java.lang.String</method-param>
       </method-params>
       </query-method>
       <result-type-mapping>Local</result-type-mapping>
       <ejb-ql>[CDATA[SELECT OBJECT(a) FROM Agente(a) WHERE a.login LIKE ?1]]</ejb-ql>
       </query>
      </entity>
      


      And here is the jbosscmp-jdbc.xml section relative to this bean and query:
      <entity>
       <ejb-name>Agente</ejb-name>
       (...)
       <cmp-field>
       <field-name>login</field-name>
       <column-name>LOGIN</column-name>
       </cmp-field>
      </entity>
      

      What could be possibly wrong?

        • 1. Re: EJB-QL Problem in jboss-3.0.0beta
          pazu

          It seems the the forum messed up a bit with my XML. The CDATA sections *are* correct, the forums stripped the preceding <! and the following >.

          But the rest seems to be correct. So, who knows how to help me? :)

          • 2. Re: EJB-QL Problem in jboss-3.0.0beta
            jcarroll

            You can't use LIKE with input parameters in EJB-QL. You may be able to override this in the jboss specific query, but I'm not sure since I never use them and didn't try it. If you want an exact match (which I think you do) just use the = operator instead of LIKE.

            • 3. Re: EJB-QL Problem in jboss-3.0.0beta
              pazu

              Strange it may be, but I have LIKE in other queries and JBoss don't complain about them. Strange... I think I'll update JBoss to the newest tip so I can use the new EJB-QL compiler.