[hibernate-issues] [Hibernate-JIRA] Updated: (HHH-2320) Regression: optional properties under a <join> tag no longer update properly

Gail Badner (JIRA) noreply at atlassian.com
Thu Apr 5 17:37:04 EDT 2007


     [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-2320?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Gail Badner updated HHH-2320:
-----------------------------

    Attachment: HHH-2320.patch

I'm attaching a patch for this issue. I've tested it using the test case attached to this ticket. I've also run the unit tests using this patch and it did not seem to introduce any problems.

This patch contains the following changes:
- adds determineRowCount() to the Expectation interface and makes protected implementations public
- adds method Expectations::NONE.determineRowCount() which always returns -2, which means that the number of affected rows is unknown
- changes AbstractEntityPersister.check() to return:
      expectation.determineRowCount(rows, statement) > 0 
when StaleStateException is caught and the table is "nullable" (e.g., association is optional)

This should only change the behavior of the method when the number of affected rows is less than expected, the table is "nullable", and no rows were updated. When these conditions are satisfied, false will be returned.

Gail Badner
SourceLabs - http://www.sourcelabs.com
Dependable Open Source Systems

> Regression: optional properties under a <join> tag no longer update properly
> ----------------------------------------------------------------------------
>
>                 Key: HHH-2320
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2320
>             Project: Hibernate3
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 3.2.0.cr4, 3.2.0.cr5, 3.2.0.ga, 3.2.1
>         Environment: hibernate 3.2.0.cr4 through 3.2.1.ga
> hsql 1.8.0.7 and Oracle 9i
>            Reporter: Chris Jones
>         Attachments: HHH-2320.patch, OptionalJoinTest.jar
>
>
> This was specifically introduced with the revision 10217 changes on the 3.2 branch in src/org/hibernate/persister/entity/AbstractEntityPersister.java
> Given the following setup:
> <class name="Thing">
>   <id .../>
>   <join table="JOIN_TABLE" optional="true">
>     <key column="THING_ID" not-null="true"/>
>     <property name="joinedProperty" column="JOINED_PROPERTY"/>
>   </join>
> </class>
> scenario:
> Thing thing1 = new Thing();
> thing1.setJoinedProperty("thing1");
> save(thing1);
> // a record in the JOIN_TABLE is created properly and updates on the property can occur
> Thing thing2 = new Thing();
> thing2.setJoinedProperty(null);
> save(thing2);
> // no record in JOIN_TABLE is created
> thing2.setJoinedProperty("thing2");
> save(thing2);
> // in revision 10216, hibernate correctly runs an INSERT to create a JOIN_TABLE record with the value "thing2"
> // in revision 10217, hibernate incorrectly runs an UPDATE to try and update a non-existant record in the JOIN_TABLE with the thing2 id
> It looks like the expectation.verifyOutcome() method should be throwing a StaleStateException if the attempted update effects 0 rows.
> I will try and get an official hibernate testcase going and possibly a patch, but I wanted to enter this now in case there is something I'm missing that makes this change in functionality intentional.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list