I was using EntityLoadByExample today and the behavior wasn't what I was
expecting.

I expected it would be able to replace the query I always do right before
insert (the "check" query) - to make sure that the insert wont conflict with
unique constraints.

Ive bee using it like this:

x = entityNew("a")

x.setP1("...")
x.setP2("...")
[...n]

if(isNUll(EntityLoadByExample(x)))
 x.save()
else
 x = EntityLoadByExample(x)

This works great whenever all the properties for "a" are simple
(fieldtype=column).

But when I tried this with an object that has a many-to-one defined, it
ignores this difference.

I've dumped x and EntityLoadByExample(x) right next to each other and see
that the "parent" object in the two dumps are different (different data, to
include pks).

Right now Im using

arrayLen(EntityLoad("a",{p1='#p1#',p2='#p2#',p3='#parent#'})) eq 0 in place
of isNUll(EntityLoadByExample(x)).

This seems to do the trick. But does anyone know if I know
if EntityLoadByExample should be able to handle this?


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
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:329191
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to