11 Replies Latest reply on Sep 19, 2002 4:00 PM by Dain Sundstrom

    order in finders

    Christopher Jozsa Newbie

      JBoss3 question:

      Anyone can please show me a tested and working EJB-QL query for CMP2 beans using the 'order' tag? I've tried a few, and the tag is just completely ignored..

      Christopher

        • 1. Re: order in finders
          Scott Hurst Newbie

          I am haveing the exact same problem.

          jboss version 3.0.0


          findAll
          <![CDATA[ 1 = 1]]>
          agencyName


          What is most interesting, some of them are working just fine and are written in exactly the same way.

          • 2. Re: order in finders
            Scott Hurst Newbie

            A bit of extra data for my problem.

            I am using EJB1.1 descriptors. Working on a large initial port of a weblogic 5.1 app. Once this is done, a full port to EJB2 will be done.

            Anyway, doing the 1.1 style port just to have a version up and running quickly on jboss and the 2.0 port will be a major overhaul of the app.

            • 3. Re: order in finders
              Dain Sundstrom Master

              It will be easier to start with an EJB 2.0 dd in CMP 1.1 backward compatability mode. Then you can use the jbosscmp-jdbc.xml which is also the cmp 2.0 file and you can use EJB-QL, JBossQL, and the ther query specs.

              • 4. Re: order in finders
                Dain Sundstrom Master

                also upgrade to 3.0.2

                • 5. Re: order in finders
                  Scott Hurst Newbie

                  OK, have it running on 3.0.2.

                  If you could elaborate a bit on your above message, that may be very useful.

                  I take it you are saying I should be using the JBOSSCMP-JDBC instead of the jaws file?

                  • 6. Re: order in finders
                    Scott Hurst Newbie

                    This is getting maddening.

                    I moved to 3.0.2 with no improvement. I've tried some variations on things all to no effect it is still ignoring the tags for just SOME of the entities. (Actually I know of only one for certain out of about 120 entities deployed).

                    I see no differences between the ones that work and the one that doesn't.

                    • 7. Re: order in finders
                      Scott Hurst Newbie

                      update: Probably a related symptom.

                      I tried adding an additional finder to an existing entity in the system.

                      I added:

                      in beanhome.java

                      public Collection getEm()
                      throws FinderException, RemoteException;


                      in jaws.xml

                      getEm
                      <![CDATA[ 1=1]]>
                      agencyName


                      At deployment time I get an error indicating: Depends On Me: org.jboss.deployment.DeploymentException: Could not find matching method for public abstract java.util.Collection com.forelogic.flhcs.agency.AgencyHome.getEm() throws javax.ejb.FinderException,java.rmi.RemoteException]

                      This indicates that the jaws.xml is not getting reprocessed for some reason.

                      As a further test, I removed the finder tags for existing beans trying to force a new error and the beans continue to work fine with the finder tags removed from the jaws.xml file.

                      So far, I have done an ant clean then build and also deleted all the the tmp deployed files in the jboss/server/default/tmp dir to force them to completely redeploy at server start up. So far, it is like I have not made a single change to the jaws.xml file at all.

                      • 8. Re: order in finders
                        Scott Hurst Newbie

                        Resolution:

                        Two discoveries:

                        1) If you name a finder method with anything that doesn't start with the word "find" it doesn't work. Appearently jboss requires finders to begin that way.
                        2) method name "findAll" appears to be a special case and ignores the order by tags.

                        • 9. Re: order in finders
                          L.G. Newbie

                          Are you using ejb-jar.xml or jbosscmp-jdbc.xml to define the query? In case you are using ejb-jar.xml it would be ejb-ql and by the specs it does not support <order by>. You need to override it in jbosscmp-jdbc.xml with jboss extention (DynamicQL or DeclaredQL).
                          About by the specs it must start with

                          • 10. Re: order in finders
                            Scott Hurst Newbie

                            I am using the jaws.xml for this version of the project. It does support the tags.

                            • 11. Re: order in finders
                              Dain Sundstrom Master

                              The requirement on find is from the EJB specification. I suggest you get a good book on EJB like the O'Reilly one, which explains how to run a CMP 1.1 entity in an EJB 2.0 application.

                              When you do get the CMP 1.1 entities setup with a 2.0 dd, you can start to use EJB-QL in the ejb-jar.xml file, and jboss-ql, which supports a order by clause, in the jbosscmp-jdbc.xml file. For more information on that I suggest you get the JBossCMP documentation.