[hibernate-issues] [Hibernate-JIRA] Updated: (HHH-2895) PersistentBag.key is not updated when a bag key refer to a non-id property that is generated by database

Christian Bauer (JIRA) noreply at atlassian.com
Wed Oct 17 11:31:39 EDT 2007


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

Christian Bauer updated HHH-2895:
---------------------------------

    Priority: Minor  (was: Critical)

> PersistentBag.key is not updated when a bag key refer to a non-id property that is generated by database
> --------------------------------------------------------------------------------------------------------
>
>                 Key: HHH-2895
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2895
>             Project: Hibernate3
>          Issue Type: Bug
>    Affects Versions: 3.2.0.ga
>         Environment: Hibernate 3.2.0ga and newer. Oracle 10g.
>            Reporter: Igor Spasic
>            Priority: Minor
>         Attachments: HibernateProblem.zip
>
>
> Have 2 entities (Customer & Address) in one-to-many relationship.
> Customer.linkId is not the id of customer, still, it is used for relationships with the addresses. Moreover, Customer.linkId is generated by database triger.
> So, the testcase is:
> + open tx
> + create customer and add two addresses to it
> + commit tx
> + open new tx
> + update customer object
> + commit
> the exception is:
> Exception in thread "main" org.hibernate.HibernateException: Don't change the reference to a collection with cascade="all-delete-orphan": yc.hibprob.Customer.addresses
> This is not true, since collection is not changed at all.
> Some hints:
> i assume that when hibernate reads generated linkId from database, it doesn't update it in PersistentCollection used for relationships. When I debug, i see that key property of PersistentBad is set to -1 after the first transaction, and it should be set to value of Customer.linkId. When I manually change the key in debuger during runtime, problem is solved.
> Take a look at the enclosed example, it contains complete example and sql script.
> Moreover, notice the Customer constructor - i had to initalize the linkId, otherwise hibernate will give NullPointerException. huh:)
> Please provide me some feedback regarding this issue. Maybe configuration is wrong or we are doing something wrong here. Just do not rant about the database model, it is something what is fixed and set by our customers, so we cant change it ;) Also, we would like to use 'all-delete-orphan', since if cascade is set to 'all', there will be no problem. 

-- 
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