Lookup Entities

Posts   
 
    
MikeP
User
Posts: 40
Joined: 27-May-2007
# Posted on: 05-Jun-2010 18:11:38   

I have a Journey entity which has a ‘one to many’ relationship to the ‘Leg’ entity (i.e. a journey can have many legs).

The business layer always fetches the Journey entity together with all Leg entities (through prefetch path). Similarly the BL saves the Journey entity recursively which makes sure all changes within the Leg entities are saved as well.

Now to my question. The leg entity includes (for example) a StartLocation which has a ‘many to one’ relationship to the Location entity. It is very convenient to prefetch the Location entity for each leg’s StartLocation entry when fetching the Journey entity. This allows me to directly access the location entity through the leg entity – great!

However because I am saving the Journey recursively I am worried that someone (another programmer) for example would allow the user to set the Locations properties to another value (i.e. change the location name) which would then get persisted to the DB (where the Location entity is only there for lookup purposes).

Really what I would like to achieve when working with the Journey entity is that only values within the Journey and Legs can be changed but none of the extra entities I only prefetch for convenience i.e. lookup purposes.

Which approach do you think would work best to make these fetched items read-only?

The only solution I can think of at the moment is to not prefetch the ‘lookup Entities’ with the Journey entity but use a lookup mechanism when accessing these entities however it seems very cumbersome.

I could change the save mechanism of the Journey entity i.e. remove the recursive save and save each Journey and Leg entity individually which would prevent any changes of these items to be persisted into the database. However if possible I would even like to prevent changes to be made in memory.

Any thoughts?

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 06-Jun-2010 22:59:58   

I will go with LLBLGen Authorizers. They were designed for that, please read in the documentation about Authorization, in your case is very simple as you just need to denied save permission to everybody.

David Elizondo | LLBLGen Support Team