Menu

Delete objects with multi-leve relations.

T.Mo
2005-04-16
2013-03-07
  • T.Mo

    T.Mo - 2005-04-16

    I got a 3 objects: CustomerCategory, Customer, Order

    It shall behave like this: if i delete a category, all customers under the category shall be deleted, and all orders under each deleted customer shall be deleted also.

    In xml mapping file, i aready set the autodelete to true.

    now, back to my problem, i must populate the customercollection in customer category in order to delete customers away, and i must populate OrderCollection in each deleted customer before i can delete all orders! Another way is that to use DeleteCriteria. But, still, a lot of database queries must be done before i can remove all related data entries from database.

    This shall not be the best way in handling with relational database, right?

    Maybe there is another better way in the framework, please advise me ....

     
    • Richard Banks

      Richard Banks - 2005-04-20

      Sorry for the delay in responding - it's been busy :-)

      You're right about the delete not being done the best way, however at the moment I haven't implemented a better solution.

      If I get some time soon, I'll try an implement a better delete, but in the meantime could you create an entry in the Requests (RFE) section so that I have a reminder (and so you'll see when things get updated).

      - Richard.

       
    • Nobody/Anonymous

      Hello,
      in my opinion, such cases should be handled by the database and not by the programming logic.

      A correct implementation of foreign keys with a delete cascade resolves that in a very elegant way....

      uh

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.