• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Enforcing uniqueness of data
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Enforcing uniqueness of data


  • Subject: Re: Enforcing uniqueness of data
  • From: email@hidden
  • Date: Thu, 8 Sep 2005 15:32:58 +0200


Hi!

While the unique index is the fail safe method, I would augment it with a check using a fetch specification during validateForSave().

That check should catch all duplicates except the ones created simultaneously. You'll probably never run into the database exception thrown by the unique index.

It is then OK to invest less effort in handling that specific database exception. You might actually get away with catching just any EOGeneralAdaptorException and showing a basic error message: Failed to create the account. Please try again. If duplication really was the problem, validateForSave will catch the mistake on the next attempt.

Pierre

webobjects-dev-bounces+pierre.bernard=email@hidden wrote on 09/07/2005 09:08:50 PM:

> Put a UNIQUE INDEX on the login field in the database table and then  
> handle the error when changes are saved (try - catch). You will get a  
> general adaptor exception which you need to examine and check that the  
> error is caused by trying to insert a row which violates the unique  
> key. This technique is useful and can also be used for unique  
> combinations of attributes.
>
> On Sep 7, 2005, at 1:00 PM, Daniel Eggert wrote:
>
> > I need the login of my user EO to be unique. Since the login is  
> > something the user enters, it is not the PK.
> >
> > How would I go about ensuring this? If I fetch from the database and  
> > then write if it is unique, someone might be able to write to the  
> > database in the meantime.
> >
> > This post
> >      
> > <http://lists.apple.com/archives/webobjects-dev/2004/Jun/
> > msg00249.html>
> > suggests locking. Is it a sane approach? How would I do such a thing  
> > with EOF?
> >
> > Thanks in advance.
> >
> > /Daniel
> >
> > _______________________________________________
> > Do not post admin requests to the list. They will be ignored.
> > Webobjects-dev mailing list      (email@hidden)
> > Help/Unsubscribe/Update your Subscription:
> > email@hidden
> >
> > This email sent to email@hidden
> >
>
>  _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Webobjects-dev mailing list      (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
>


**********************************************************************
This email and any files transmitted with it are intended solely for
the use of the individual or entity to whom they are addressed.
If you have received this email in error please notify the sender
of this message. (email@hidden)
This email message has been checked for the presence of computer
viruses; however this protection does not ensure this message is
virus free.
Banque centrale du Luxembourg; Tel ++352-4774-1; http://www.bcl.lu
**********************************************************************
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Enforcing uniqueness of data
      • From: Chuck Hill <email@hidden>
References: 
 >Re: Enforcing uniqueness of data (From: Kieran Kelleher <email@hidden>)

  • Prev by Date: Problem with objectsWithFetchSpecification
  • Next by Date: Re: DirectAction URLs
  • Previous by thread: Re: Enforcing uniqueness of data
  • Next by thread: Re: Enforcing uniqueness of data
  • Index(es):
    • Date
    • Thread