2 Replies Latest reply on Nov 26, 2002 5:18 PM by Erik Sliman

    Explicit Mapping for 1-M Relationship

    Erik Sliman Apprentice

      The problem I am having is that JBoss does not know what the foreign key is when doing a joining a 1-M in a CMR query unless I specify it as the <cmr-field-name>. However, this is incorrect usage of the tag, as it should be your abstract accessor method for the get/set for the related object, not the foreign key. You run into a problem using the foreign key when you try navigation with dot notation.

      I discovered that Oracle's J2EE implementation requires that you explicitly map the foreign key in their separate descriptor, comparable to jbosscmp-jdbc. They call this:

      Explicit Mapping of Relationship Fields to the Database

      I could not find any similar mapping technique available for JBoss. How do we support object navigation with DOT notation while also explicitly telling JBoss what foreign key to use in a join?

        • 1. Re: Explicit Mapping for 1-M Relationship
          Mattia Newbie

          it is documented in JBoss.3.0QuickStart.Draft3.pdf section "Relationship Mapping" at page 83.


          • 2. Re: Explicit Mapping for 1-M Relationship
            Erik Sliman Apprentice

            I read that many times over, and never understood exactly how you syntactically map a foreign key, and the examples do not show you.

            I did figure it out though when I read a January post regarding 3.0.0 alpha, using a foreign key tag that is no longer valid in the jbosscmp-jdbc DTD. I had suspected by this point that the key-fields tag had something to do with this, but could not find a valid example, and nothing truly explaining what column-name was truly used for.

            I finally realized it might be the placeholder for the foreign key reference when I searched for the dated foreign-key-fields tag in the JBossCMP.pdf, only to find a reference in the Revision History stating that it was somehow merged with the key-fields element, hinting that I should pursue my original hunch. I experimentally tried using the column-name tag, and sure enough, it worked!

            Boy was I happy. I spent a whole day trying to figure this one out. I would really love to see the documentation updated to more clearly explain this tag, and the criticalness of using it in a one-to-many, to save others the time and frustration I went through.