SaveEntity method

Posts   
 
    
meetarifmd
User
Posts: 3
Joined: 13-May-2008
# Posted on: 13-May-2008 11:46:32   

Hi All,

Can anyone give me answers to the confusion. This is related to an entityToSave and all its related entities. What would happen in the following scenarios.

I have the following entity. 1)entityToSave.anotherEntityID (foreign key to the other entity) 2)entityToSave.anotherEntity (obtained thru prefetchpath, representing the above anotherentityID) 3)entityToSave.otherEntityCollection (another collection of objects thru prefetchpath)

when i say adapter.save(entity, refetchAfterSave, recurse) what will happen in below cases for 1, 2, 3 things.

refetchAfterSave recurse 1 2 3 true true true false false true false false

when i change anotherEntityID, with the refetchAfterSave(true) and recurse(true) would save fetch me with the new anotherEntity.

what am most interested is when will the saveEntity will get me the entityToSave with all its prefecth paths. I want this within the save method.

Walaa avatar
Walaa
Support Team
Posts: 14994
Joined: 21-Aug-2005
# Posted on: 13-May-2008 12:44:31   

have the following entity. 1)entityToSave.anotherEntityID (foreign key to the other entity) 2)entityToSave.anotherEntity (obtained thru prefetchpath, representing the above anotherentityID) 3)entityToSave.otherEntityCollection (another collection of objects thru prefetchpath)

when i say adapter.save(entity, refetchAfterSave, recurse) what will happen in below cases for 1, 2, 3 things.

refetchAfterSave recurse 1 2 3 true true true false false true false false

To sum it up, Recurse = true, will recursively save all entities in the graph. i.e. if the main saved entity had related entity objects associated with it, they will be saved into the database, in case they are dirty or new.

This doesn't include entities referenced in the database but not linked in the saved graph.

refetchAfterSave = true, will refetch each and every entity saved in the graph. (Main entity only in case of recurse = false, every other saved entity, in case of recurse = true)

when i change anotherEntityID, with the refetchAfterSave(true) and recurse(true) would save fetch me with the new anotherEntity.

No entity would be fetched unless it was already in the graph.

what am most interested is when will the saveEntity will get me the entityToSave with all its prefecth paths. I want this within the save method.

No, you will have to call a fetch method. In other words, you will have to fetch the graph. Use PrefetchPaths to fetch related entities.