• 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: Newbie question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Newbie question


  • Subject: Re: Newbie question
  • From: Amiel Montecillo <email@hidden>
  • Date: Thu, 07 Apr 2011 11:59:42 +0800

I agree with Chuck. To display a more meaningful error message, I've been putting a mapping in my ValidationTemplate.strings something like:

"User.USERNAME_DUP_IDX" = "Username already exists";

where 
User = modelname
USERNAME_DUP_IDX = name of your unique index.

HTH,
Amiel

On Thu, Apr 7, 2011 at 11:48 AM, Chuck Hill <email@hidden> wrote:
That is going to leave you with a race condition.  The only certain way to prevent the creation of duplicates is to put an unique constraint on the database.  Then you have to catch the database exception (EOGeneralAdaptorException) in your code and handle appropriately.  The ugly part is that the exception message returned is different for each database which makes doing this in a database agnostic way slightly challenging.

Chuck

On Apr 6, 2011, at 8:21 PM, Paul D Yu wrote:

> Based on the column/attribute in your DB/EOModel that would make your consider the record/EO to be duplicate of another, you should implement a method that would check for those values in the existing set.
>
> I don't think there is a one line solution to what you are seeking.
>
> Paul
> On Apr 6, 2011, at 10:52 PM, Mr Tonnew wrote:
>
>> Hi,
>>
>> How do I avoid committing duplicate entries in the DB? I have a form
>> from where I take entries. Is there a single line of code that can
>> accomplish this?
>>
>> MR
>> _______________________________________________
>> 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
>
> _______________________________________________
> 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

--
Chuck Hill             Senior Consultant / VP Development

Practical WebObjects - for developers who want to increase their overall knowledge of WebObjects or who are trying to solve specific problems.
http://www.global-village.net/products/practical_webobjects








 _______________________________________________
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


 _______________________________________________
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

References: 
 >Newbie question (From: Mr Tonnew <email@hidden>)
 >Re: Newbie question (From: Paul D Yu <email@hidden>)
 >Re: Newbie question (From: Chuck Hill <email@hidden>)

  • Prev by Date: Re: Newbie question
  • Next by Date: Re: Concurrent request handling
  • Previous by thread: Re: Newbie question
  • Next by thread: Re: Newbie question
  • Index(es):
    • Date
    • Thread