hyperjaxb
  1. hyperjaxb
  2. HYPERJAXB-13

Problem creating one to many (or maybe many-to-one) relationship

    Details

    • Type: Task Task
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: current
    • Fix Version/s: milestone 1
    • Component/s: hyperjaxb-hibernate
    • Labels:
      None
    • Environment:

      Operating System: Linux
      Platform: All

    • Issuezilla Id:
      13

      Description

      An issue for the original mail sent to the discussion forum:

      <a
      href="https://hyperjaxb.dev.java.net/servlets/ReadMsg?list=users&msgNo=146">https://hyperjaxb.dev.java.net/servlets/ReadMsg?list=users&msgNo=146</a>

      1. ControllerServlet.java
        13 kB
        gjacobi
      2. UserBO.java
        2 kB
        gjacobi
      3. users.xsd
        8 kB
        gjacobi

        Activity

        Hide
        gjacobi added a comment -

        Created an attachment (id=2)
        My xsd

        Show
        gjacobi added a comment - Created an attachment (id=2) My xsd
        Hide
        gjacobi added a comment -

        Created an attachment (id=3)
        The object that tries to persist the xml

        Show
        gjacobi added a comment - Created an attachment (id=3) The object that tries to persist the xml
        Hide
        gjacobi added a comment -

        Created an attachment (id=4)
        This servlet has code that creates a valid "user" object and passes it to UserBO to be persisted.

        Show
        gjacobi added a comment - Created an attachment (id=4) This servlet has code that creates a valid "user" object and passes it to UserBO to be persisted.
        Hide
        gjacobi added a comment -

        I learned a little more. you were right, my issue was with the 'unsaved-value'.
        For some reason, eventhough I did not set the 'id' for my address object, its
        value was zero. I changed unsaved value to '0' and it tried to do the insert.

        But, I now have another problem. The insert did not attempt to set the
        foreign_key (in this case, user_id) on the insert and my database has a
        constraint that forces this not be null.

        Now, I imagine I could go ahead and model my xml to have this user_id field be
        part of the address complexType but since address is always a child of user it
        seems quite redunant.

        Any ideas? And thanks for pointing me in the right direction.

        (note, I am posting this to the mailing list also just in case anybody else is
        having the same problem)

        Show
        gjacobi added a comment - I learned a little more. you were right, my issue was with the 'unsaved-value'. For some reason, eventhough I did not set the 'id' for my address object, its value was zero. I changed unsaved value to '0' and it tried to do the insert. But, I now have another problem. The insert did not attempt to set the foreign_key (in this case, user_id) on the insert and my database has a constraint that forces this not be null. Now, I imagine I could go ahead and model my xml to have this user_id field be part of the address complexType but since address is always a child of user it seems quite redunant. Any ideas? And thanks for pointing me in the right direction. (note, I am posting this to the mailing list also just in case anybody else is having the same problem)

          People

          • Assignee:
            lexi
            Reporter:
            gjacobi
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: