Automatic setting EntityState to Fetched configurable per entity

Posts   
 
    
Robert.W
User
Posts: 79
Joined: 19-Jun-2007
# Posted on: 30-Oct-2007 11:52:00   

Hi,

I was just reading the: Setting the EntityState to Fetched automatically after a save topic in the documentation and it seems setting that per entity is not currently supported. Is this something that is planned for the future release? If not I would make that a feature request.

Robert.

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 30-Oct-2007 12:09:44   

Currently the EntityBase.MarkSavedEntitiesAsFetched is a static property, i.e. for all entities.

I'll put this in our feature requests queue.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 30-Oct-2007 18:25:11   

You want to specify for example to set 'customer' to fetched when saved always and for example another entity's state shouldn't be set as Fetched after save?

Could you give a reason why you want to differ that per entity type?

Frans Bouma | Lead developer LLBLGen Pro
Robert.W
User
Posts: 79
Joined: 19-Jun-2007
# Posted on: 30-Oct-2007 19:58:29   

I guess for the same reason why you want to set it for all entities. I can imagine a scenario in which one of the entities is affected by a trigger (or has a default value defined for a column) and all other are not. In that case we're devoting performance on all entites for the sake of being certain we are working with consistent data for that single entity.

Honestly I don't need it right now as I can live without default values in the database which are probably not one of the best practices anyway, but I'm thinking about the future when someone will actually want to put a trigger on one of the database tables in production (because they want to save on application integration costs). Wouldn't it be nice if I could then tell LLBLGen:

<entitySaveBehavior entityName="TriggerAffectedEntity" autoRefetch="true" /> <entitySaveBehavior entityName="CustomerEntity" autoRefetch="false" markFetchedOnSave="true" />

(Notice that the really flexible solution would involve more than just setting the state to Fetched).

Maybe I'm being a little bit too paranoid about it but something doesn't feel right when I have to set this behavior for each and every entity.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 31-Oct-2007 10:47:55   

If it really matters for performance to not fetch the entity again and for example you need to disable the behavior on one or two, then it indeed could be helpful, although I do think it's really an edge case, as in general the default behavior: you need to refetch the entity if you want to re-use the data in the entity, is the better choice: it's more reliable because you don't run the risk of enabling the check for refetching on an entity you should have.

The refetch is always your call, it's never a thing done by LLBLGen Pro on its own in Adapter. So keeping the default behavior will set the OutOfSync state on entities, which is fine if you don't read the data again from the same entity instance. If you DO read the data (non-PK fields) again from the object without refetching it, you get an exception. The setting we're talking about makes the state to be set to Fetched, so you don't get the exception. That's basicly it: if you don't need to fetch the entity again, you won't get the roundtrip anyway as you always have to make the refetch call yourself (or by specifying that llblgen pro should refetch it after the save in the save routine)

Frans Bouma | Lead developer LLBLGen Pro