Man... I was getting excited at the prospect that CF would read the DB
structure, see the unique constraints on a table, realizes all the needed
properties were defined and try to identify it. Afterall, I just realized
the docs say "ColdFusion automatically tries to find if a new record should
be inserted or an existing record be updated for the given entity..." But it
looks like that means it just checks to see if the object has a value for
the pk or not?
So in the scenario that I don't already have a variable handle to the
object, or know its PK, but I do have the "real world" defining elements, it
looks like I'll have to search for it.
This is why the mentioned pattern (entitynew -> loadbyexample -> [user
returned or create new]) seemed so appetizing - if an existing entity is not
found, I already have the un-persisted entity I used for loadbyexample with
the bare essentials specified, and just have to use entitySave() on it.
I need to look at the debug stack to see which search-mechanism
(loadbyexample, load('',...criteria...),hql) is most efficient. Also, it'll
be interesting to see if running loadbyexample(a) twice right after each
other would cause to DB pulls, or if the second run will use the ORM cache
(not because theres any good reason to run them twice - but just to see how
the affect).
For any process having to do this type of task, doing anymore than 2 DB
calls per object is unacceptable - 1 to try to identify and 1 to do the save
if it doesn't already exist.
thanks for talking through this with me!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
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:329208
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4