1 2 Previous Next 22 Replies Latest reply on May 22, 2002 10:31 AM by dsundstrom

    EJB-QL LIKE clause

    romeriz

      Hello all,

      I am trying to use the LIKE clause in a finder and
      I seem to be having a problem. I am declaring my clause as
      follows:

      <ejb-ql>
      <![CDATA[SELECT OBJECT(o) FROM CompanyBean AS o WHERE o.companyname LIKE ?1]]>
      </ejb-ql>

      Can anyone point me in the correct direction?

      Regards,

      Stephen.

        • 1. Re: EJB-QL LIKE clause
          dsundstrom

          EJB-QL does not support parameters in the like clause, but JBossQL does. To use JBossQL copy your query element to the jbosscmp-jdbc.xml file, and change ejb-ql to jboss-ql. For more information on the proper formatting of the jbosscmp-jdbc.xml file see the dtd.

          http://www.jboss.org/j2ee/dtd/jbosscmp-jdbc_3_0.dtd

          • 2. Re: EJB-QL LIKE clause
            romeriz

            Thanks for that. Does anyone know how you would achieve a similar result in EJB-QL?

            Thanks.

            Stephen.

            • 3. Re: EJB-QL LIKE clause
              shogun

              Extract the jboss.jar and search for it.

              • 4. Re: EJB-QL LIKE clause
                dsundstrom

                You can't; that's why I wrote JBossQL.

                • 5. Re: EJB-QL LIKE clause
                  morphace

                  You can achieve a similar result by using the LOCATE function (which produces a more expensive query of course).



                  • 6. Re: EJB-QL LIKE clause
                    semm

                    This doesn't work in EJB-QL, but shouldn't it ?
                    ....
                    WHERE o.name LIKE CONCAT(?1, '%')

                    • 7. Re: EJB-QL LIKE clause
                      dsundstrom

                      Read the grammar in the spec. The patters must be a string literal. I could easily add this to JBossQL, but I won't unless it is widely supported.

                      • 8. Re: EJB-QL LIKE clause
                        cwbrandon

                        Dain,

                        Will or does JBossQL support a max function?

                        • 9. Re: EJB-QL LIKE clause
                          dsundstrom

                          Will. I think Antonio is about to start on this. Aggregate function are part of the forth coming EJB 2.1 specification.

                          • 10. Re: EJB-QL LIKE clause
                            cwbrandon

                            Cool, so since it will be part of the EJB-QL 2.1 spec I guess JBossQL won't have to support it.

                            • 11. Re: EJB-QL LIKE clause
                              dsundstrom

                              Until they release the spec this will only be in JBossQL.

                              • 12. Re: EJB-QL LIKE clause

                                Hi,

                                I've try to develop a "like" statement in jbosscmo-jdbc.xml but at deploy time, it complains :

                                "ERROR [XmlFileLoader] XmlFileLoader: File file:/users/vol1/gardais/app-serv/jboss-3.0.0beta/tmp/deploy/89.facade-jms-like.jar!/META-INF/jbosscmp-jdbc.xml process error. Line: 84. Error message: Element "query" does not allow "jboss-ql" here."

                                After studying the DTD, i see no explanation for that behaviour as the query tag allows "(jboss-ql|dynamic-ql|declared-ql)?"


                                Does anybody know why do i get this message ?


                                INFO [Server] JBoss (MX MicroKernel) [3.0.0beta Date:200202210220]


                                jbosscmp-jdbc.xml uses the following doctype :
                                <!DOCTYPE jbosscmp-jdbc PUBLIC
                                "-//JBoss//DTD JBOSSCMP-JDBC 3.0//EN"
                                "http://www.jboss.org/j2ee/dtd/jbosscmp-jdbc_3_0.dtd">


                                thanks for any help,
                                ionel

                                • 13. Re: EJB-QL LIKE clause
                                  dsundstrom

                                  Order matters. Make sure you have the tags in the same order. If that doesn't work post the query section.

                                  • 14. Re: EJB-QL LIKE clause

                                    Hi,

                                    I was wondering if order matters or not and you give me the answer.

                                    I've check for the order thing already.
                                    It doesn't solve my problem.

                                    Here is my Query section :




                                    selectionne les personnes dont le nom commence par ...
                                    <query-method>
                                    <method-name>findByNameLike</method-name>
                                    <method-params>
                                    <method-param>java.lang.String</method-param>
                                    </method-params>
                                    </query-method>
                                    <jboss-ql>select distinct object(p) from personneBean p where p.nom like ?1</jboss-ql>





                                    I've try it with and without the same query declared in the ejb-jar.xml but the problem remains.

                                    I also get an error message from JBoss when deploying a query in jbosscmp-jdbc.xml that wasn't declared in ejb-jar.xml such as "no matching request in ejb-jar.xml" or something like this.

                                    But when I include the same request in the ejb-jar file, it complains that "like" isn't supported.


                                    Any ideas,
                                    thanks for your help,
                                    ionel

                                    1 2 Previous Next