Table locks will definitely work, because they'll prevent anyone from
inserting a new record (with a new username) between the time you
check the username and the time you insert it.  It's exactly the same
as a CFLOCK, except it happens to a DB table, not a block of
application code.  However, I agree that the unique key is the final
and absolute check for uniqueness, and really, if you have that in
place, then the rest of it is pretty much irrelevant.

userHome also acts as a factory for user objects, and for pulling
collections of them as well.  I might want a recordset of user info
for rendering a table of users.  But I might want a collection of user
objects for expiring passwords on them (or whatever).  If you're
familiar with EJBs, it'd be like the Home interface for an entity
bean.  Obviously they don't match up exactly because of enormous
environmental differences, but at a high level they are roughly
equivalent.

cheers,
barneyb

On Wed, 3 Nov 2004 14:08:22 -0800, Phil Cruz <[EMAIL PROTECTED]> wrote:
> On Wed, 3 Nov 2004 13:35:06 -0800, Barney Boisvert <[EMAIL PROTECTED]> wrote:
> 
> 
> > userHome is a gateway, among a other things.
> >
> > You might be right about the lock.  Depends on how your database
> > implements the transactional locking.  You can certainly do a
> > read-only table lock for the check, and then escalate the lock to
> > exclusive for the INSERT and know you've gotten it beaten that way.
> > Or, you just assume it works (which it should), and let the unique key
> > in the database be your ultimate safeguard.  Didn't I just say that I
> > never trust keys a couple messages ago?  I'm such a liar.  ;)
> >
> > I'm not sure why Sean didn't bring up transactions in that message on
> > the Mach-II list.  Maybe he knows something I don't.  CFLOCK is
> > definitely an effective way to ensure integrity (assuming all access
> > is via your CFC, a restriction transactions and/or DB locks don't
> > have), but I don't think it's a necessary one.  Maybe he'll chime in
> > and explain why I'm wrong, as he is so good at doing?
> >
> > cheers,
> > barneyb
> 
> This is a great discussion.  Thanks for sharing your thoughts (in detail).
> 
> I don't think the readonly/exclusive db locks will do the trick.  I
> think databases do implement common mechanism for transactional locks
> for uniqueness. It's called a "unique key" ;)
> 
> On another note, what does userHome do besides gateway functions?
> 
-- 
Barney Boisvert
[EMAIL PROTECTED]
360.319.6145
http://www.barneyb.com/blog/

I currently have 0 GMail invites for the taking
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev' 
in the message of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).

An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL PROTECTED]

Reply via email to