• 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: Automatic indexing solution
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Automatic indexing solution


  • Subject: Re: Automatic indexing solution
  • From: Kieran Kelleher <email@hidden>
  • Date: Tue, 19 Jul 2005 09:48:15 -0400

Flor,

Just make another entity/table like EO_PK_TABLE named for example "SERIAL_NUMBER" and each row in the table maintains the last used serial number for a certain type. One row could be for "invoice" serial numbers, another for "booking" numbers, etc.

Then use SQL in a synchronized static method to grab the next serial number using optimistic style locking just as EOF does when generating primary keys. To see this in action, log out the SQL and watch the SQL that grabs PK's from the EO_PK_TABLE when saving new entities.

The SQL steps are
1) SELECT the row in the SERIAL_NUMBER table where serial_type equals "booking"
2) Increment the serial number
3) TRY to update the "booking" row WHERE the serial number equals the OLD number and the serial_type equals "booking" (this is like an optimistic locking update which only succeeds if no other app has updated in the meantime.
4) If the update fails repeat steps 1 to 3 up to N max retries until you successfully get a new number.


HTH, Kieran

On Jul 19, 2005, at 8:43 AM, Florijan Stamenkovic wrote:


On Jul 19, 2005, at 13:07, Florijan Stamenkovic wrote:

Add an isSaving boolean to Application. Upon user invoking saveChanges() in my component first checking if the app is unlocked, then locking the "saving process" on application level through (setIsSaving(true)), fetching the last record, update new records with booking numbers, save the to the database, unlock the app for saving, display the records to the user so they can do what they want with the booking numbers of those records. Since all is happening in one method, I could make a try / catch / finally block to make sure that the boolean for allowing saving does not stay set to false if an exception is thrown.

Darn, then it is still possible to have another instance making a request for the last booking record in between the first instance getting the last number and saving it's new records. How about declaring the boolean in Application as static???


Flor

_______________________________________________
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
  • Follow-Ups:
    • Re: Automatic indexing solution
      • From: Florijan Stamenkovic <email@hidden>
References: 
 >Automatic indexing solution (From: Florijan Stamenkovic <email@hidden>)
 >Re: Automatic indexing solution (From: Florijan Stamenkovic <email@hidden>)

  • Prev by Date: Re: Automatic indexing solution
  • Next by Date: Re: Webobjects-dev Digest, Vol 2, Issue 411
  • Previous by thread: Re: Automatic indexing solution
  • Next by thread: Re: Automatic indexing solution
  • Index(es):
    • Date
    • Thread