• 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
Best way to generate unique IDs that are not PKs
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Best way to generate unique IDs that are not PKs


  • Subject: Best way to generate unique IDs that are not PKs
  • From: Florijan Stamenkovic <email@hidden>
  • Date: Sun, 31 Dec 2006 16:11:31 +0100

Hi all,


I have a need in several of my tables to generate identifying numbers, but relative to a certain relationship. So, if there is a Book, I need to generate number 6 for it if Author currently relates to 5 other books... I have an approach of doing this, please anyone tell me if there is a better way to do it!


My approach:

1. Lock the working thread on a monitor that is "static final" in my SessionWorker class
2. Get the next number by using aBook.valueForKeyPath ("email@hiddeneNumber"); //can not use @count in case of previous deletions
3. Set the next number in aBook
4. Save the changes of my working editing context
5. Release the synchronization lock


Questions:
Is there way to use EOF locking to lock on the database? It seems to me that would be more appropriate for what I am doing then the plain Java thread synching, and would work even if there were multiple application servers running, where the above approach would not. Any other ideas where this might flop and how to prevent it?



Thanks! Florijan _______________________________________________ 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: Best way to generate unique IDs that are not PKs
      • From: Sacha Michel Mallais <email@hidden>
    • Re: Best way to generate unique IDs that are not PKs
      • From: shaun <email@hidden>
  • Next by Date: Web Service Client Hello World
  • Next by thread: Re: Best way to generate unique IDs that are not PKs
  • Index(es):
    • Date
    • Thread