0

I use Unit of work pattern to commit all new, dirty, deleted entities to the DB (using a db_mapper).

Example of entities are: Student and Class

So Student->registerDirty() will add this entity to the dirty pool that will be saved to the DB when commit() will be called.

My problem is that Student can also hold collection of classes (Student->getClasses) and I am not sure how to integrate this into the unit of work pattern so it will only commit the new, updated or deleted.

Can any one recommend me how to integrate this?

asked Oct 19, 2014 at 11:16

1 Answer 1

1

Simple : the collection of Classes will record what was added or removed and will commit those items accordingly.

answered Oct 19, 2014 at 19:44
2
  • So you suggest tracking changes inside the collection class? and then add the whole collection to the UoW. Then commit() will also loop on all 'dirty' collections? Commented Oct 20, 2014 at 13:33
  • @michaelbn Yeah. That could work. Commented Oct 20, 2014 at 14:33

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.