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

Re: Consistent reads


  • Subject: Re: Consistent reads
  • From: Chuck Hill <email@hidden>
  • Date: Wed, 6 Dec 2006 14:26:31 -0800


On Dec 6, 2006, at 2:13 PM, Miguel Arroz wrote:

I was having a small discussion about ORB mapping frameworks, and I found out something that I could not solve with WO, at least with the knowledge I have.


My question is, how can I make sure that, when I'm reading several objects from the DB, they are consistent with each other?

  Imagine I have:

  EOEditingContext context = new EOEditingContext();
  SomeEOObject object1 = readObject1(context);
  // comment
  SomeEOObject object2 = readObject2(context);

  NSLog.out.appendln(object1.someProperty());
  NSLog.out.appendln(object2.someProperty());

  context.dispose();

So, it's a read-only operation that displays values from data stored. My question is, how can I make sure that object1 and object2 are consistent between each other?

You can't. If they are related, you can do a fetch, with prefetching key paths to fetch both objects in the same transaction. If they are not related, does being consistent between each other matter?



There could be some other instance of the application modifying objects 1 and 2 right on my "comment" line. So, I'm reading object1 BEFORE that operation, and object2 AFTER that operation. Their values would not be consistent between each other.

And some other process could modify the database immediately after you read the second making them inconsistent with the database. ORM or not, that can happen.


As I never commit (because there's no changes) I cannot use optimistic locking to detect this inconsistence.

No. But optimistic locking only detects inconsistencies between the memory and DB version. If the two objects were consistent when read, but lated changed in the DB you would get an optimistic locking exception.



How do you solve this kind of problem? Locking the rows would not work, because I may have a more complex example where I can know what object2 is only after getting object1, so I would only lock object2 after fetching object1, and the problem would be the same.

If prefetching won't do it, I am not even sure what the problem is. :-)


Chuck

--

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


References: 
 >Consistent reads (From: Miguel Arroz <email@hidden>)

  • Prev by Date: Consistent reads
  • Next by Date: Re: How do I use JAVA Frame instead of WOFrame in my app
  • Previous by thread: Consistent reads
  • Next by thread: Re: Consistent reads
  • Index(es):
    • Date
    • Thread