Uploaded image for project: 'The AndroMDA project'
  1. ANDROMDA-373

One-to-many associations inverse attribute in Hibernate mapping incorrect

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:

      Linux 2.6.8, Mac OS X 10.3, and Windows XP Professional

      Description

      We have an issue with one-to-many associations and how the Hibernate mapping files get generated. Here is the relationship:

      ---------------- -------------------

      • Order - 1 <>-----------------> * - OrderItem -
                                    • -------------------

      In the Hibernate mapping file the following gets generated for the association on each end:

      Order.hbm.xml
      <set name="order" order-by="ORDER_FK" lazy="false" inverse="true" cascade="all-delete-orphan">
      <key>
      <column name="ORDER_FK"/>
      </key>
      <one-to-many class="foo.OrderImpl"/>
      </set>

      OrderItem.hbm.xml
      <many-to-one name="order" class="com.dwango.cornerstone.role.OrderImpl" >
      <column name="ORDER_FK"/>
      </many-to-one>

      The problem is in the first Hibernate mapping of Order. The attribute "inverse=true" causes database errors when we load data through the OrderImpl.setOrderItems(Collection) method and send it to the DAO create(Order). We are using MySQL for our database and it does not persist the data for the association collection. If the inverse attribute is change to "false" then the association collection is persisted.

        Attachments

          Activity

            People

            • Assignee:
              overheat overheat
              Reporter:
              csterwa Chris Sterling
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: