You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by "Dinkar Rao (JIRA)" <ji...@apache.org> on 2008/12/22 20:16:44 UTC

[jira] Created: (OPENJPA-843) Unnecessary version update on inverse-side of a 1-m relationship

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

                 Key: OPENJPA-843
                 URL: https://issues.apache.org/jira/browse/OPENJPA-843
             Project: OpenJPA
          Issue Type: Bug
          Components: jdbc
    Affects Versions: 2.0.0
            Reporter: Dinkar Rao
            Priority: Minor


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. 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (OPENJPA-843) Unnecessary version update on inverse-side of a 1-m relationship

Posted by "Catalina Wei (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENJPA-843?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Catalina Wei resolved OPENJPA-843.
----------------------------------

       Resolution: Fixed
    Fix Version/s: 2.0.0
                   1.3.0
                   1.2.1
         Assignee: Dinkar Rao

Patch has been commited at following svn revisions:
trunk : r733932
1.3.x:  r733945
1.2.x:  r733944

> Unnecessary version update on inverse-side of a 1-m relationship
> ----------------------------------------------------------------
>
>                 Key: OPENJPA-843
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-843
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jdbc
>    Affects Versions: 2.0.0
>            Reporter: Dinkar Rao
>            Assignee: Dinkar Rao
>            Priority: Minor
>             Fix For: 1.2.1, 1.3.0, 2.0.0
>
>         Attachments: OPENJPA-843-test.patch, OPENJPA-843.patch
>
>
> 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. 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (OPENJPA-843) Unnecessary version update on inverse-side of a 1-m relationship

Posted by "Dinkar Rao (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENJPA-843?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dinkar Rao updated OPENJPA-843:
-------------------------------

    Attachment: OPENJPA-843-test.patch

> Unnecessary version update on inverse-side of a 1-m relationship
> ----------------------------------------------------------------
>
>                 Key: OPENJPA-843
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-843
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jdbc
>    Affects Versions: 2.0.0
>            Reporter: Dinkar Rao
>            Priority: Minor
>         Attachments: OPENJPA-843-test.patch, OPENJPA-843.patch
>
>
> 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. 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (OPENJPA-843) Unnecessary version update on inverse-side of a 1-m relationship

Posted by "Dinkar Rao (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENJPA-843?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dinkar Rao updated OPENJPA-843:
-------------------------------

    Attachment: OPENJPA-843.patch

In the patch, the call to updateIndicators() is made only under these conditions:

- any non-relational field of the entity is modified
- any relationships owned by the entity are modified.

The flag (updateIndicators) to decide whether versions/discriminators should be modified is passed in recursively to update(), to take care of the case where the version field is in a superclass whose fields have not been modified, but the subclass' fields have been modified. 

> Unnecessary version update on inverse-side of a 1-m relationship
> ----------------------------------------------------------------
>
>                 Key: OPENJPA-843
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-843
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jdbc
>    Affects Versions: 2.0.0
>            Reporter: Dinkar Rao
>            Priority: Minor
>         Attachments: OPENJPA-843.patch
>
>
> 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. 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.