6 Replies Latest reply on Jul 1, 2002 12:47 PM by xlahaut

    CMP2 ejbSelect method.

    xlahaut Newbie

      I've got a problem with my ejbSelect method. Here is the corresponding EJB-QL :
      SELECT OBJECT(l) FROM Letter AS l WHERE l.template.logicalName = ?1

      Letter is a Bean with a OneToMany relationship with a Template Bean which has an CMP field logicalName. The problem is that the request returns no result while the data are correctly present in the DB.


        • 1. Re: CMP2 ejbSelect method.
          Lance Cranford Newbie

          I think the proper way to declare one-to-many relationships in EJB-QL is as follows:

          SELECT OBJECT(l) FROM Letter AS l, IN (l.template) t WHERE t.logicalName = ?1

          You have to use the IN clause when dealing with collections as a cmr field. I'm assuming that template is defined as a collection or set in the Letter Bean

          • 2. Re: CMP2 ejbSelect method.
            xlahaut Newbie

            The CMR field template is not a collection, the one to many relation ship is define like this in my ejb-jar.xml :


            So in this case I don't need to use the IN keyword. My ejbSelect method is used in a ejbHome method in the LocalHome interface of the LetterBean. All of my beans are deployed in the same JVM. Have you got any other suggestions ?


            • 3. Re: CMP2 ejbSelect method.
              Dain Sundstrom Master

              Are you getting errors? What is the generated SQL? Does it look correct? Try executing the sql by hand in your database.

              • 4. Re: CMP2 ejbSelect method.
                xlahaut Newbie

                No, I do not have any errors, it's simply does not return the result I'm waiting for. I don't known how to see the generated sql request. Could you tell me how to ?


                • 5. Re: CMP2 ejbSelect method.
                  Dain Sundstrom Master

                  The should be in the server.log. If they are not, you will need to increase the log level of the org.jboss.ejb.plugins.cmp category to DEBUG in the log4j.xml file. Directions are contained in the log4j.xml file.

                  • 6. Re: CMP2 ejbSelect method.
                    xlahaut Newbie

                    Here is the generated sql request :

                    SQL: SELECT t0_l.ID_LETTER, t0_l.APPLICATION_NUMBER, t0_l.GENERATION_DATE, t0_l.SENT_DATE, t0_l.FAX_COVER_PAGE, t0_l.owner, t0_l.storeLocation, t0_l.recipient, t0_l.description, t0_l.status, t0_l.storageType, t0_l.storageReference, t0_l.ID_ENTITY_FK, t0_l.ID_TEMPLATE_FK FROM LETTER t0_l, TEMPLATE t1_l_template WHERE (t1_l_template.LOGICAL_NAME = ?) AND (t0_l.ID_TEMPLATE_FK=t1_l_template.ID_TEMPLATE)

                    It seems to be normal, I do not see where the problem. I've got the impression that the object Template is not in the object Pool just when I sent the request.