7 Replies Latest reply on Jan 28, 2003 10:43 AM by triathlon98

    problem in ejbSelect

      Hi,

      I have tried this query for an ejbSelect and it does not seem to work:

      I have two schemas "Task" and "Bag" and there is a 1-n relation mapping between "Task" and "Bag" : A "Task" ownes several "Bag" with the cmr field "bags"

      here is the query for the ejbSelect :


      <query-method>
      <method-name>ejbSelectBags</method-name>
      <method-params>
      TaskLocal</method-param>
      </method-params>
      </query-method>
      <ejb-ql>SELECT t.bags FROM Task AS t WHERE t.id = ?1.id</ejb-ql>


      And here is the error produced :

      Could not deploy, Cause:
      java.lang.IllegalStateException:
      Unknown path: t.bags

      Could someone give me some help ? Thanks you

        • 1. Re: problem in ejbSelect
          kryptontri

          should you not define your cmr relationships ? or have you ? jaws will not know what t. means ? have you defined your relationships like this [ taken from CMP docs : purchase online ]


          <ejb-relation>
          <ejb-relation-name>Order-LineItem</ejb-relation-name>
          <ejb-relationship-role>

          <!-- exdented to fit on a printed page -->
          <ejb-relationship-role-name>order-has-lineitems</ejb-relationship-role-name>

          One
          <relationship-role-source>
          <ejb-name>OrderEJB</ejb-name>
          </relationship-role-source>
          <cmr-field>
          <cmr-field-name>lineItems</cmr-field-name>
          <cmr-field-type>java.util.Collection</cmr-field-type>
          </cmr-field>
          </ejb-relationship-role>
          <ejb-relationship-role>

          <!-- exdented to fit on a printed page -->
          <ejb-relationship-role-name>lineitem-belongsto-order</ejb-relationship-role-name>
          Many
          <cascade-delete/>
          <relationship-role-source>
          <ejb-name>LineItemEJB</ejb-name>
          </relationship-role-source>
          <cmr-field>
          <cmr-field-name>order</cmr-field-name>
          </cmr-field>
          </ejb-relationship-role>
          </ejb-relation>


          ??

          what about your foreign key mapping ?


          <ejb-relation>
          <ejb-relation-name>Order-LineItem</ejb-relation-name>
          <foreign-key-mapping>

          <ejb-relationship-role>

          <!-- exdented to fit on a printed page -->
          <ejb-relationship-role-name>order-has-lineitems</ejb-relationship-role-name>

          <foreign-key-fields/>
          </ejb-relationship-role>

          <ejb-relationship-role>

          <!-- exdented to fit on a printed page -->
          <ejb-relationship-role-name>lineitem-belongsto-order</ejb-relationship-role-name>

          <foreign-key-fields>
          <foreign-key-field>
          <field-name>ordernumber</field-name>
          <column-name>ORDER_NUMBER</column-name>
          </foreign-key-field>
          </foreign-key-fields>
          </ejb-relationship-role>

          </foreign-key-mapping>
          </ejb-relation>



          Does this make sense to you ? I have not done cmp2.0 yet i will in a few weeks time. I hope this helps ?

          • 2. Re: problem in ejbSelect

            Of course I have declared the relation :

            in the ejb-jar :

            <ejb-relation>
            <ejb-relation-name>BagBean-TaskBean</ejb-relation-name>
            <ejb-relationship-role>
            <ejb-relationship-role-name>BagBean-has-TaskBean</ejb-relationship-role-name>
            Many
            <relationship-role-source>
            <ejb-name>BagBean</ejb-name>
            </relationship-role-source>
            <cmr-field>
            <cmr-field-name>task</cmr-field-name>
            </cmr-field>
            </ejb-relationship-role>
            <ejb-relationship-role>
            <ejb-relationship-role-name>TaskBean-has-BagBeanCollection</ejb-relationship-role-name>
            One
            <relationship-role-source>
            <ejb-name>TaskBean</ejb-name>
            </relationship-role-source>
            <cmr-field>
            <cmr-field-name>bags</cmr-field-name>
            <cmr-field-type>java.util.Collection</cmr-field-type>
            </cmr-field>
            </ejb-relationship-role>
            </ejb-relation>

            in the jbosscmp-jdbc.jar :

            <ejb-relation>
            <ejb-relation-name>BagBean-TaskBean</ejb-relation-name>
            <foreign-key-mapping>
            <ejb-relationship-role>
            <ejb-relationship-role-name>BagBean-has-TaskBean</ejb-relationship-role-name>
            <fk-constraint>false</fk-constraint>
            <foreign-key-fields>
            <foreign-key-field>
            <field-name>iD</field-name>
            <column-name>TASK_ID</column-name>
            </foreign-key-field>
            </foreign-key-fields>
            </ejb-relationship-role>
            <ejb-relationship-role>
            <ejb-relationship-role-name>TaskBean-has-BagBeanCollection</ejb-relationship-role-name>
            <fk-constraint>false</fk-constraint>
            <foreign-key-fields/>
            </ejb-relationship-role>
            </foreign-key-mapping>
            </ejb-relation>

            • 3. Re: problem in ejbSelect
              dsundstrom

              This is a bug in the EJB-QL parser. It was discovered and fixed after the alpha was released. The fix is in cvs.

              • 4. Re: problem in ejbSelect

                I tried cvs yesterday but I had a problem :

                DataSources weren't bound into JNDI, so I had to use jboss3.0 alpha again.

                is this normal ? maybe there is a feature that I have not activated at build time

                • 5. Re: problem in ejbSelect

                  I have posted a test case on sourceforge as a bug.
                  Please keep me informed with the issue as I am very interested by using this kind of ejbSelect

                  best regards Julien

                  • 6. Re: problem in ejbSelect
                    bongosdude

                    I am using Jboss 3.0.4 and I got this bug too. Can someone show me how to get the patch from pvcs. What files do I need to download.

                    Thanks

                    • 7. Re: problem in ejbSelect
                      triathlon98

                      Why are you creating a ejbSelect method?

                      Have a good look at the CMP documentation which can be bought online. You are trying to query a relationship, so make sure you define it as bidirectional and just expost a "abstract Collection getBags()" method in your Task. Everything should work automagically.

                      Joachim