First I used your example posted, so your eample has that IsNULL error to begin with.
Secondly, I am not sure why you need to retrieve the record again? When you create an Entity, and then populate it and after saving there is no need to retrieve it again as everything that is in the DB is populated in the Entity. If you are needing something more, then I suggest looking into optimistic locking. ColdFusion 9 ORM allows a developer to define 2 more fields for this exact behaviour. One is called version, and the other is timestamp. You can either use one of the other, or both depending on how tight you want to make this. But at the end of the day reloading an Entity that has been saved is only actually just wasting a DB call, as it will always be the same in this situation you describe regardless. There maybe more to what you are doing, but from what you have mentioned your work flow process is overkill. On Thu, Dec 17, 2009 at 10:07 AM, Charlie Stell <[email protected]>wrote: > > Thanks for the reply Andrew, > > I'm not sure I follow where your going with your suggestion of :" > x = EntityLoadByExample(x) > if(isNUll(x)) > x.save()" > > "x.save()" would throw in error in the case that x is null. > > In the majority of cases where this check is needed, it's a case of "create > if needed, retrieve the instance either way" - so with a try/catch I would > still need to retrieve the existing record. > > However, even in cases where I want to enforce uniqueness, relying only on > a > try-catch here requires that the unique constraint *actually* exist in the > database (which it certainly should - but even if it doesn't, it represents > a requirement to have "clean" clean ) and would likely end up leaving that > portion of the business logic separate from whats in the application layer > (I'm looking into how much of this can be housed solely in the ORM mapping > files via uniquekey). > > But regardless of why EntityLoadByExample is being called, I still would > expect it to to only return instances matching all defined properties - > both > data and object properties - still cannot nail down why it's not behaving > this way. > > -Charlie > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:329202 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

