Menu

Delete objects

2004-09-13
2004-09-15
  • Nobody/Anonymous

    Hi,

    I has the following structure:

    Object A has many objects B. (OneToMany)
    Object A is persistent in the database, and it have four objects B (B1, B2, B3, B4). I want remove B2, it's execute correctly in cache but how the object A has not changed, the changes in the database  have not been executed.

    I try A.setdirtyFlag, but nothing.

    I has execute b2.remove or not ?

    Saludos

    Victor (Madrid - Spain)

     
    • Nobody/Anonymous

      Hi,

      the same problem with add a object

      Saludos

      Victor (Madrid - Spain)

       
    • Richard Banks

      Richard Banks - 2004-09-15

      Hi Victor,

      Removing an object from a collection will not delete it from the database as it is possible that the object is referenced elsewhere, and that it is possible that the object is valid on its own.

      To delete the object you will need to specifically call the delete() method.

      For Object A, you have to make sure that the collection knows about it's parent or that the parent captures the events of the collection.  There are two ways to do this:

      1.  Set the collections .Parent() property when the collection is instantiated.  eg ObjBCol.Parent = Me

      - or -

      2.  Capture the events on the collection and set Object A's dirty flag as needed (requires that the collection be declared as "withevents" in vb, or that you add events handlers)

      - Richard

       

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.