Loading ...
Sorry, an error occurred while loading the content.

Re: Dependency

Expand Messages
  • comfortablementeadormecido
    Hi, Yes the references are nullified indeed, but I ment a cascading removal of elements that are dependant of the existance of a certain object. Using the same
    Message 1 of 5 , Jul 17, 2006
    View Source
    • 0 Attachment
      Hi,

      Yes the references are nullified indeed, but I ment a cascading
      removal of elements that are dependant of the existance of a certain
      object.
      Using the same example as before: If each State has a Collection of
      Cities, when a State is removed, and if the existance of a City
      depends on the existance of the corresponding State, then every City
      for that state should be removed as well.
      Currently the references to the state are set to NULL (by means of
      this query = "'UPDATE city SET state=NULL WHERE
      state='.strval($this->id)") but then every city that has its State
      attribute set to NULL should be removed one by one. Besides, the
      persistance of objects with references to other objects set to null is
      invalid as a default behaviour. By means of deleting a State you would
      be settig every city for that State in an invalid 'situation' (the
      word 'state' would have been confusing :p ).

      Perhaps I'm getting this all wrong, please correct me if I am. As I
      said before I really put a lot of faith in this project as I think it
      would be a great help in my job but I still cant convince myself that
      the application is fully capable of satisfying my needs. I hope that
      by means of questions liike this I am helping clarify and possibly
      correct the functionality of the project and not just annoying you.

      Thanks for your time and dedication,

      Matías

      --- In metal-dev@yahoogroups.com, Manuel Lemos <mlemos@...> wrote:
      >
      > Hello,
      >
      > on 07/12/2006 03:12 PM comfortablementeadormecido said the following:
      > > I keep playing around with metastorage and another thing came to my
      > > attention.
      > >
      > > There is no way to set a dependency between objects. For instance,
      > > imagine you have the entities State and City, when you delete a state
      > > every city for that state shoud be deleted in order to mantain
      > > consistency with the data in the City table (many of them would retain
      > > an id to a deleted State). This is obviously easy to do by setting a
      > > delete method for the cities and state and another method for the
      > > state which would get its collection, call the delete method in each
      > > city and then call delete for the current state or a similar
      algorithm.
      > > But i think it could be considered for a future release that when you
      > > set the collection relation you could set such things so you don't end
      > > up with two functions to delete a state (the standard and the
      custom one).
      > >
      > > What do you think?
      >
      > This is already done. When an object is deleted, it is removed from any
      > collections that it used to belong. If there are any objects with
      > reference variables pointing to the object being deleted, those
      > reference variables are set to NULL.
      >
      > --
      >
      > Regards,
      > Manuel Lemos
      >
      > Metastorage - Data object relational mapping layer generator
      > http://www.metastorage.net/
      >
      > PHP Classes - Free ready to use OOP components written in PHP
      > http://www.phpclasses.org/
      >
    • Manuel Lemos
      Hello, Sorry for the delay. ... If you want to remove cities that belong to a state, you can delete the city objects one by one and they automatically will be
      Message 2 of 5 , Aug 8, 2006
      View Source
      • 0 Attachment
        Hello,

        Sorry for the delay.

        on 07/17/2006 02:18 PM comfortablementeadormecido said the following:
        > Yes the references are nullified indeed, but I ment a cascading
        > removal of elements that are dependant of the existance of a certain
        > object.
        > Using the same example as before: If each State has a Collection of
        > Cities, when a State is removed, and if the existance of a City
        > depends on the existance of the corresponding State, then every City
        > for that state should be removed as well.
        > Currently the references to the state are set to NULL (by means of
        > this query = "'UPDATE city SET state=NULL WHERE
        > state='.strval($this->id)") but then every city that has its State
        > attribute set to NULL should be removed one by one. Besides, the
        > persistance of objects with references to other objects set to null is
        > invalid as a default behaviour. By means of deleting a State you would
        > be settig every city for that State in an invalid 'situation' (the
        > word 'state' would have been confusing :p ).
        >
        > Perhaps I'm getting this all wrong, please correct me if I am. As I
        > said before I really put a lot of faith in this project as I think it
        > would be a great help in my job but I still cant convince myself that
        > the application is fully capable of satisfying my needs. I hope that
        > by means of questions liike this I am helping clarify and possibly
        > correct the functionality of the project and not just annoying you.

        If you want to remove cities that belong to a state, you can delete the
        city objects one by one and they automatically will be removed from the
        collections they they belonged.

        Cascaded deletes can be dangerous. Even if the database supports them, a
        simple mistake may wipe the whole database. I never used them. As a
        matter of fact, usually I have a removed flag in objects that I may want
        to check past information later, rather than actually delete them.

        That does not mean it cannot be done. It means it can be done with
        proper care. I have just added it to the todo list now so I can
        implement it when I have more time.

        http://www.meta-language.net/metastorage-progress.xml

        --

        Regards,
        Manuel Lemos

        Metastorage - Data object relational mapping layer generator
        http://www.metastorage.net/

        PHP Classes - Free ready to use OOP components written in PHP
        http://www.phpclasses.org/
      • comfortablementeadormecido
        Thank you for your attention Manuel. Regards, Matías
        Message 3 of 5 , Aug 9, 2006
        View Source
        • 0 Attachment
          Thank you for your attention Manuel.

          Regards,
          Matías

          --- In metal-dev@yahoogroups.com, Manuel Lemos <mlemos@...> wrote:
          >
          > Hello,
          >
          > Sorry for the delay.
          >
          > on 07/17/2006 02:18 PM comfortablementeadormecido said the following:
          > > Yes the references are nullified indeed, but I ment a cascading
          > > removal of elements that are dependant of the existance of a certain
          > > object.
          > > Using the same example as before: If each State has a Collection of
          > > Cities, when a State is removed, and if the existance of a City
          > > depends on the existance of the corresponding State, then every City
          > > for that state should be removed as well.
          > > Currently the references to the state are set to NULL (by means of
          > > this query = "'UPDATE city SET state=NULL WHERE
          > > state='.strval($this->id)") but then every city that has its State
          > > attribute set to NULL should be removed one by one. Besides, the
          > > persistance of objects with references to other objects set to null is
          > > invalid as a default behaviour. By means of deleting a State you would
          > > be settig every city for that State in an invalid 'situation' (the
          > > word 'state' would have been confusing :p ).
          > >
          > > Perhaps I'm getting this all wrong, please correct me if I am. As I
          > > said before I really put a lot of faith in this project as I think it
          > > would be a great help in my job but I still cant convince myself that
          > > the application is fully capable of satisfying my needs. I hope that
          > > by means of questions liike this I am helping clarify and possibly
          > > correct the functionality of the project and not just annoying you.
          >
          > If you want to remove cities that belong to a state, you can delete the
          > city objects one by one and they automatically will be removed from the
          > collections they they belonged.
          >
          > Cascaded deletes can be dangerous. Even if the database supports them, a
          > simple mistake may wipe the whole database. I never used them. As a
          > matter of fact, usually I have a removed flag in objects that I may want
          > to check past information later, rather than actually delete them.
          >
          > That does not mean it cannot be done. It means it can be done with
          > proper care. I have just added it to the todo list now so I can
          > implement it when I have more time.
          >
          > http://www.meta-language.net/metastorage-progress.xml
          >
          > --
          >
          > Regards,
          > Manuel Lemos
          >
          > Metastorage - Data object relational mapping layer generator
          > http://www.metastorage.net/
          >
          > PHP Classes - Free ready to use OOP components written in PHP
          > http://www.phpclasses.org/
          >
        Your message has been successfully submitted and would be delivered to recipients shortly.