Inq Forums
September 08, 2010, 01:32:16 am *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Inq 1.0.2 - Hello World example added
 
   Home   Help Search Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: create()  (Read 828 times)
cjohn
Member

Posts: 1


« on: November 27, 2008, 10:51:14 am »

Hi !

I appreciate that I can:
1. Open a txn
2. Create an object
3. Commit the txn - object gets written to database.
4. Do a non-unique read such that the created object is expected to be part of the set. I assume Inq will call the database via a select-stmt.

Then the set will contain the object created in step2.

However, if I now do the:
1. Open a txn
2. Create an object
3. Do a non-unique read such that the created object is expected to be part of the set
4. Commit the txn

How will my set of read objects contain the created object from step2?

Should I use a eligible-clause in my i/o key defn ???
Logged
Tom
Member

Posts: 1


Email
« Reply #1 on: November 27, 2008, 03:22:53 pm »

I think there is some confusion surrounding the Inq transaction model and (separately) what an eligibility expression is for.

First the transaction issue. Inq does not behave in the same way as (at least some) database servers do.
After you have called create() the instance you have submitted for creation will not be returned by subsequent read() calls until the transaction has successfully committed, so your first scenario is correct. Step 3 in the second scenario is incorrect - the instance you created will not be in the set. Inq only returns managed instances - that is ones that have been previously committed.

Secondly the eligibility expression. The purpose of an eligibility expression is to maintain cached key values and the instance(s) they map to when the underlying SQL contains an inequality. It is not (as you perhaps have misunderstood) intended to help Inq return instances awaiting formal creation when read() is called.

You might ask why doesn't Inq return to-be-created instances in a read() ? Well, once an instance has been submitted for creation Inq does not allow it to be changed. This is because Inq locks the unique key value(s) the instance represents to protect the transaction's integrity. More on transaction state can be found here: http://www.inqwell.com/primer/txn.html#manip
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2008, Simple Machines LLC Valid XHTML 1.0! Valid CSS!