On Wed, 3 Nov 2004 10:55:52 -0800, Barney Boisvert <[EMAIL PROTECTED]> wrote:
> > Can you elaborate on how you do unique username type of validation if
> > you don't let the db throw the unique key error? Seems like you might
> > have to implement some locking scheme?
>
> Transactions. Since the entire operation (BO validation and
> persistance) happens as a single call to the business layer, it's all
> in a single transaction. Another reason for not putting this stuff in
> the input validation - that forces you to have per-request
> transactions, which generally isn't what you want.
>
> some psuedo code for the method in the service object:
>
> function addUser(username, password)
> throws ValidationException
> {
> start transaction;
> var bo = userFactor.getNewUser();
> bo.setUsername(username); // throws ValidationException if invalid
> bo.setPassword(password); // throws ValidationException if invalid
> persist(bo);
> commit transaction;
> }
>
Can you provide psuedo code for setUsername()? I'm not clear on how
you are checking for uniqueness. You aren't hitting the db to check
for an existing username or are you?
-Phil
----------------------------------------------------------
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]