[OmniBase] Commiting changs to an existing object

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[OmniBase] Commiting changs to an existing object

Yar Hwee Boon-3
Hi all,

Playing with OmniBase and the examples, I was wondering what I should do  
to commit the changes to x in the workspace code below? I notice that in  
the examples, it seems that x is always re-read again from root before  
making any changes. What if I have more than 1 reference to the same  
object (ie. x and y), such that I can only do something like "x  
markDirty"? Thanks.

dbPath := File tempPath, 'omnibase1234'.
db := OmniBase createOn: dbPath.
x := OrderedCollection new.
y := x. "y is assumed to be used somewhere else"
x add: 'abc'.
[OmniBase root at: 'test' put: x makePersistent] evaluateAndCommitIn: db  
newTransaction.
"[(OmniBase root at: 'test') inspect] evaluateIn: db newTransaction."
x add: 'yyy'.
["x markDirty." "what should I do here to commit the changes made to x?"]  
evaluateAndCommitIn: db newTransaction.
db close

--
Regards
Hwee Boon
MotionObj


Reply | Threaded
Open this post in threaded view
|

Re: [OmniBase] Commiting changs to an existing object

kuo-2
On Sun, 01 Aug 2004 01:39:37 +0800, "Yar Hwee Boon"
<[hidden email]> wrote:

Hi,

> What if I have more than 1 reference to the same  
>object (ie. x and y), such that I can only do something like "x  
>markDirty"? Thanks.
>............
>x add: 'yyy'.
>["x markDirty." "what should I do here to commit the changes made to x?"]  
>evaluateAndCommitIn: db newTransaction.
>db close
I gave my understanding, which may be not totally correct ( it should
leave to the OmniBase for final judge)

According to your code,
........  
x add: 'yyy'
.........
[  x markDirty ] evaluateAndCommitIn: db newTransaction.

I think It  won't  work, because x is not a "persistent object" ( i.e.
not inside a transaction).
 
  After transaction,  x and all the objects referenced to "x" were all
changed to a persisent object, serialized and clustered together with
a unique OID in the database.
  x was no more a persistent obejct outside a  transaction, so, cann't
be markDirty or committed again.  

    So, if you want to do something to the persistent "x", you should
get it from the database inside a new transaction again.
i.e.

[  x := OmniBase root at: 'test'.
   x add: 'yyy'
   x markDirty ] evaluateAndCommitIn: db newTransaction.


Reply | Threaded
Open this post in threaded view
|

Re: [OmniBase] Commiting changs to an existing object

Yar Hwee Boon-3
On Mon, 02 Aug 2004 00:13:13 +0800, kuo <[hidden email]> wrote:

>     So, if you want to do something to the persistent "x", you should
> get it from the database inside a new transaction again.
> i.e.
>
> [  x := OmniBase root at: 'test'.
>    x add: 'yyy'
>    x markDirty ] evaluateAndCommitIn: db newTransaction.

Thanks for the respond. Indeed, that is so, but what I meant was:

> On Sun, 01 Aug 2004 01:39:37 +0800, "Yar Hwee Boon"
> <[hidden email]> wrote:
>
>> What if I have more than 1 reference to the same
>> object (ie. x and y), such that I can only do something like "x
>> markDirty"? Thanks.

Note that I had another reference y which is used elsewhere, eg. as a  
model of a shell which is still open. So I was wondering if it was  
possible to *not* do it as the examples were (and which was what you  
suggested above). Because this way, y will be pointing to a totally  
different object. And will affect perhaps alot of code that was written  
before any database was used. How does OmniBase or probably other OODBMS  
users handle this?

--
Regards
Hwee Boon
MotionObj