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

Automatic indexing solution


  • Subject: Automatic indexing solution
  • From: Florijan Stamenkovic <email@hidden>
  • Date: Tue, 19 Jul 2005 13:07:27 +0200

Hi all.

I am working on a book keeping suite. There are booking numbers that are something like unique indexes of records. We use a convention of plain integers there (makes my life easy :). They should be automatically generated. I DON'T want to use the pk for this.

BUT, the booking numbers should be visible to the user that is creating records. So, the user creates a record and would like to see what booking number he / she is on If two users are adding records at the same time, both of them will be starting from the same last booking number -> meaning they will not be so unique after saving to the database. So, I figured that if I allow concurrent users to work in the db, the booking numbers should be generated using something like this:

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.

Any comment on this solution???

Oh, one more thing. To get the "last" record / records I create an EOFetchSpecification with a sort ordering on the attribute I want the "last" to be qualified by, and setFetchLimit(int x) on the specification to 1 or whatever. Is this generally the way to do this?
Example:
...
EOSortOrdering so = new EOSortOrdering("bookingNumber", EOSortOrdering.CompareDescending);
EOFetchSpecification fs = new EOFetchSpecification("Booking", null, new NSArray(so));
fs.setFetchLimit(1);
NSArray lastBooking = ec.objectsWithFetchSpecification(1); //hoping to results with only the last booking record in this array
//do tests and throw exceptions if...
...


Thanks in advance,
Flor

_______________________________________________
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>
  • Prev by Date: Re: custom formatter
  • Next by Date: Re: Automatic indexing solution
  • Previous by thread: How do you add java -D Option to Build?
  • Next by thread: Re: Automatic indexing solution
  • Index(es):
    • Date
    • Thread