UnitOfWork - Guarantee Order?

Hi Experts

When putting multiple object types in a UnitOfWork, does it guarantee that the objects will be saved in that order?

For instance, in my script I create a new AccProduct (using IEntity), and put it in a uow. I also create another object of a my custom table which has a FK column to the XObjectKey of the AccProduct, and I put that also in the uow. 

Something like this

Dim AccProd as IEntity = Session.Source.CreateNew("AccProduct")

...

Dim myObj as IEntity = Session.Source.CreateNew("MyTable")

..

myObj.PutValue("CCC_AccProdKey",AccProd.GetValue("XObjectKey").String))

uow.Put(AccProd)

uow.Put(myObj)

uow.Commit()

I noticed the objects get saved but the CCC_AccProdKey column on my custom table doesn't get populated., and my guess is that is because the corresponding AccProduct wasn't commited to the database first.

If I save each object individually using .Save(session) then it works as expected.

FYI - I'm adding these IEntities in a For Loop the the uow then committing outside the for loop for performance reasons.

Thanks

Kin

Parents Reply Children
No Data