OpenJPA
  1. OpenJPA
  2. OPENJPA-843

Unnecessary version update on inverse-side of a 1-m relationship

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.0.0-M2
    • Fix Version/s: 1.2.1, 1.3.0, 2.0.0-M2
    • Component/s: jdbc
    • Labels:
      None

      Description

      A Customer has 1-m relationship to Inventory:

      @Entity
      Customer {
      ....
      @OneToMany(mappedBy="customer")
      private Collection<Inventory> inventories = new ArrayList<Inventory>();
      ....
      }

      @Entity
      Inventory {
      ...
      @ManyToOne
      private Customer customer;
      ...
      }

      When an Inventory instance is modified, its version is bumped as expected. However, when an Inventory is added or deleted from the Inventory list in Customer, the Customer instance version is unnecessarily bumped up. According to section 3.4.2 of the 1.0 spec,

      "The version attribute is updated by the persistence provider runtime when the object is
      written to the database. All non-relationship fields and properties and all relationships
      owned by the entity are included in version checks."

      When additions or deletions are made to the Inventory list of Customer, the version of the Customer instance should remain unchanged. As the inverse-side, Customer does not own the Inventory that is added/deleted.

      1. OPENJPA-843-test.patch
        27 kB
        Dinkar Rao
      2. OPENJPA-843.patch
        3 kB
        Dinkar Rao

        Activity

        No work has yet been logged on this issue.

          People

          • Assignee:
            Dinkar Rao
            Reporter:
            Dinkar Rao
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development