Dear CSLA community,
We are starting a new project using a domain layer based on CSLA business objects. The dataPortal methods call a data-access-layer implemented using NHibernate repositories (DAOs).
The problem: Lets assume we have a BO with the following atributes: id (guid is the primary key) and an alternative key composed of <namesapce, name, version>. The alternative key is defined as a criteria and has a static Get() method.
Consider the following scenario: an entity is created, saved and loaded (by the alternative key). On the load step, the DAL (NHiberante) already has the original BO in its cache. But we cannot return the original object, because CSLA framework has created a new object, and the dataPortal_fetch() has only to fill it (instance method). trying to load the requested object from the DB causes an exception in NHibernate because the session now contain 2 instances with the same identity.
The question: Is it a good idea to add to augment CSLA with a static dataPortal_fetch() that will be responsible for the object creation? Am I breaking the design? Are there any un-predictble effects to such a change?
Thanks, David
David,
I'm not an expert on NHibernate but couldn't your DataPortal_Fetch call just ask the DAL for an object and expect it (the DAL) to work out if it has a cached copy to return?
Copyright (c) Marimer LLC