cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Pavel Dyadych (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (CAY-1710) Change default delete rule for runtime relationship
Date Tue, 05 Jun 2012 22:06:23 GMT

     [ https://issues.apache.org/jira/browse/CAY-1710?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Pavel Dyadych updated CAY-1710:
-------------------------------

    Description: 
It should be good to change default delete rule of runtime relationship from NO_ACTION to
NULLIFY. It will protect us from bogus references in dependent objects without reverse relationships.

Suppose we have such model:
* ARTIST(ID, NAME) ==> Artist(name, paintings)
* PAINTING(ID, NAME, ARTIST_ID, GALLERY_ID) ==> Painting(name, artist) // no reverse to
Gallery
* GALLERY(ID, NAME) ==> Gallery(name, paintings)

Delete rule of relationship Artist-toMany-Paintings is set to CASCADE. Expect that after deleting
Artist corresponding Paintings will be deleted too.. and also deleted from galleries thanks
to reverse runtime relationship Painting-toOne-Gallery created by Cayenne.

After adding data to database (print result of SelectQuery):
* Artists: Picasso
* Paintings: "Girl Reading at a Table" by Picasso
* Galleries: Metropolitan Museum of Art: ["Girl Reading at a Table" by Picasso]

After deleting object Picasso (print result of SelectQuery):
* Artists:
* Paintings:
* Galleries: Metropolitan Museum of Art: ["Girl Reading at a Table" by null] // that is BIZARRE!

This happens because when cascade delete comes to painting Girl it detects relationship with
delete rule NO_ACTION. And so gallery stays with bogus reference.

PS. After recreation of ObjectContext all bogus objects of course dissapear because they do
not exist in database.

  was:
It should be good to change default delete rule of runtime relationship from NO_ACTION to
NULLIFY. It will protect us from bogus references in dependent objects without reverse relationships.

Suppose we have such model:
* ARTIST(ID, NAME) ==> Artist(name, paintings)
* PAINTING(ID, NAME, ARTIST_ID, GALLERY_ID) ==> Painting(name, artist) // no reverse to
Gallery
* GALLERY(ID, NAME) ==> Gallery(name, paintings)

Delete rule of relationship Artist-toMany-Paintings is set to CASCADE. Expect that after deleting
Artist corresponding Paintings will be deleted too.. and also deleted from galleries thanks
to reverse runtime relationship Painting-toOne-Gallery created by Cayenne.

After adding data to database (print result of SelectQuery):
* Artists: Picasso
* Paintings: "Girl Reading at a Table" by Picasso
* Galleries: Metropolitan Museum of Art: ["Girl Reading at a Table" by Picasso]

After deleting object Picasso (print result of SelectQuery):
* Artists:
* Paintings:
* Galleries: Metropolitan Museum of Art: ["Girl Reading at a Table" by null] // that is BIZARRE!

This happens because when cascading delete comes to painting Girl it detects relationship
with delete rule NO_ACTION. And so gallery stays with bogus reference.

PS. After recreation of ObjectContext all bogus objects of course dissapear because they do
not exist in database.

    
> Change default delete rule for runtime relationship
> ---------------------------------------------------
>
>                 Key: CAY-1710
>                 URL: https://issues.apache.org/jira/browse/CAY-1710
>             Project: Cayenne
>          Issue Type: Improvement
>          Components: Core Library
>            Reporter: Pavel Dyadych
>         Attachments: helloworld-mapping.zip
>
>
> It should be good to change default delete rule of runtime relationship from NO_ACTION
to NULLIFY. It will protect us from bogus references in dependent objects without reverse
relationships.
> Suppose we have such model:
> * ARTIST(ID, NAME) ==> Artist(name, paintings)
> * PAINTING(ID, NAME, ARTIST_ID, GALLERY_ID) ==> Painting(name, artist) // no reverse
to Gallery
> * GALLERY(ID, NAME) ==> Gallery(name, paintings)
> Delete rule of relationship Artist-toMany-Paintings is set to CASCADE. Expect that after
deleting Artist corresponding Paintings will be deleted too.. and also deleted from galleries
thanks to reverse runtime relationship Painting-toOne-Gallery created by Cayenne.
> After adding data to database (print result of SelectQuery):
> * Artists: Picasso
> * Paintings: "Girl Reading at a Table" by Picasso
> * Galleries: Metropolitan Museum of Art: ["Girl Reading at a Table" by Picasso]
> After deleting object Picasso (print result of SelectQuery):
> * Artists:
> * Paintings:
> * Galleries: Metropolitan Museum of Art: ["Girl Reading at a Table" by null] // that
is BIZARRE!
> This happens because when cascade delete comes to painting Girl it detects relationship
with delete rule NO_ACTION. And so gallery stays with bogus reference.
> PS. After recreation of ObjectContext all bogus objects of course dissapear because they
do not exist in database.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message