• 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
preventing duplicate records: how to?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

preventing duplicate records: how to?


  • Subject: preventing duplicate records: how to?
  • From: Tom Woteki <email@hidden>
  • Date: Tue, 27 May 2003 12:01:04 -0400

I am seeking an alternative to an approach I have for preventing the insertion or update of records that duplicate selected fields of already existing records. My approach is based on comparing EOGlobalIDs. I keep thinking I have missed something obvious or that there may be preferred way of doing this.

Here is an example of my situation: Say I have an entity, Person, whose primary key does not involve any of N other attributes, 2 of which are firstName and surname. I want to prevent the insertion of new Persons or updating of existing Persons that would result in duplicates of these 2 attributes. (Note: These are not the only 2 attributes for which I want to avoid duplicates, so simply making their combination the primary key would not solve my problem.)

Here is the approach I use: Say p is a new Person entity I am about to insert (i.e. saveChanges() after insertObject() has been called on some editingContext). I fetch any entities whose 2 attributes from above match those of p. If I find any whose EOGlobalID in the editing context is different than p's I conclude I am about to create a duplicate and prevent the save. I use a similar technique for updates.

Is there another way, a preferred way, of doing this?

Thanks
Tom
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: preventing duplicate records: how to?
      • From: Michael Warner <email@hidden>
    • Re: preventing duplicate records: how to?
      • From: Chuck Hill <email@hidden>
  • Prev by Date: RE: Classpath for MSSQLServer JDBC Driver
  • Next by Date: Re: preventing duplicate records: how to?
  • Previous by thread: Re: installing Dev-tools to external FireWire
  • Next by thread: Re: preventing duplicate records: how to?
  • Index(es):
    • Date
    • Thread