db-jdo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Watzek <mwa.t...@spree.de>
Subject Proposal for JDO-259
Date Mon, 16 Jan 2006 15:17:05 GMT
Hi,

JDO-259 contains 4 assertions related to state 
persistent-nontransactional-dirty. Below, you find a proposal on how 
these assertions may be implemented.

Please note, that these assertions do not specify life cycle 
transitions. Instead, they specify flushing of 
persistent-nontransactional-dirty instances into the datastore at 
commit/rollback. For this reason, I propose to implement new test cases 
instead of incorporating the test cases into the existing life cycle tests.

-----------

A5.6.2-4 [If a datastore transaction is begun, commit will write the 
changes to the datastore with no checking as to the current state of the 
instances in the datastore. That is, the changes made outside the 
transaction together with any changes made inside the transaction will 
overwrite the current state of the datastore.]

Test case:

// initially make an instance persistent
pm1.begin
pm1.makePersistent(pc)
oid = pm1.getObjectId(pc)
pm1.commit

// ensure concurrent changes of the instance in the datastore
pm2.begin
pc2 = pm2.getObjectById(oid)
modify(pc2)
pm2.commit

// make the instance persistent-nontransactional-dirty
modify(pc)

// flush the instance into the datastore
pm1.begin
pm1.commit

// check the state in the datastore
check(pm3.getObjectById(oid))

-----------

A5.6.2-6 [If a datastore transaction is begun, rollback will not write 
any changes to the datastore.]

Test case:

// initially make an instance persistent
pm1.begin
pm1.makePersistent(pc)
oid = pm1.getObjectId(pc)
pm1.commit

// make the instance persistent-nontransactional-dirty
modify(pc)

// discard the changes
pm1.begin
pm1.rollback

// check the state in the datastore
check(pm3.getObjectById(oid))

-----------

A5.6.2-8 [If an optimistic transaction is begun, commit will write the 
changes to the datastore after checking as to the current state of the 
instances in the datastore. The changes made outside the transaction 
together with any changes made inside the transaction will update the 
current state of the datastore if the version checking is successful.]

Test case w/o concurrent changes:

// initially make an instance persistent
pm1.begin
pm1.makePersistent(pc)
oid = pm1.getObjectId(pc)
pm1.commit

// make the instance persistent-nontransactional-dirty
modify(pc)

// flush the instance into the datastore
pm1.begin(optimistic==true)
pm1.commit

// check the state in the datastore
check(pm3.getObjectById(oid))


Test case w/ concurrent changes:

// initially make an instance persistent
pm1.begin
pm1.makePersistent(pc)
oid = pm1.getObjectId(pc)
pm1.commit

// ensure concurrent changes of the instance in the datastore
pm2.begin
pc2 = pm2.getObjectById(oid)
modify(pc2)
pm2.commit

// make the instance persistent-nontransactional-dirty
modify(pc)

// flush the instance into the datastore
pm1.begin(optimistic==true)
pm1.commit

// check the state in the datastore
check(pm3.getObjectById(oid))

-----------

A5.6.2-10 [If an optimistic transaction is begun, rollback will not 
write any changes to the datastore. The 
persistent-nontransactional-dirty instances will transition according to 
the RestoreValues flag.]

Test case:

// initially make an instance persistent
pm1.begin
pm1.makePersistent(pc)
oid = pm1.getObjectId(pc)
pm1.commit

// make the instance persistent-nontransactional-dirty
modify(pc)

// discard the changes
pm1.begin(optimistic==true)
pm1.rollback

// check the state in the datastore
check(pm3.getObjectById(oid))

-----------

Questions:

1) The last assertion (A5.6.2-10) contains the sentence: "The 
persistent-nontransactional-dirty instances will transition according to 
the RestoreValues flag." I propose to drop the sentence from the 
assertion because the semantics of the RestoreValues flag is checked by 
other assertions related to JDO-258.

Regards,
Michael
-- 
-------------------------------------------------------------------
Michael Watzek                  Tech@Spree Engineering GmbH
mailto:mwa.tech@spree.de        Buelowstr. 66
Tel.:  ++49/30/235 520 36       10783 Berlin - Germany
Fax.:  ++49/30/217 520 12       http://www.spree.de/
-------------------------------------------------------------------

Mime
View raw message