I have a few newbie questions related to Magma, probably most of these questions are related to OODB. May be it could be useful to collect such questions.
In the end user application, is it fine to keep open a session to Magma?
After closing a Magma session, what become a local object of the persisted object?
If one re-open a session can the remote object be 'automatically' updated from the local object in case it changed?
With an open session, is it fine to read a persisted object outside of a commit:?
Is commit: only to be used when you want to persist an object?
Hilaire
In the end user application, is it fine to keep open a session to Magma?
Sure.
After closing a Magma session, what become a local object of the persisted object?
They remain in place. Where the in-memory object graph is truncated by proxies, a message agitating a proxy will cause it to re-open the session so the proxy can become the real object.
If one re-open a session can the remote object be 'automatically' updated from the local object in case it changed?
Not automatically. Updates to the repository can only be done via transactions.
With an open session, is it fine to read a persisted object outside of a commit:?
Absolutely. Other than getting the root, you don't ever really "read" an object, just send messages and proxies will be materialized.
Is commit: only to be used when you want to persist an object?
To persist an object, you must use commit.
Chris Muller a écrit :
Is commit: only to be used when you want to persist an object?
To persist an object, you must use commit.
Ok, related to this question, here is a situation we are use to: lazy initialization.
Now here is the following situation:
Let's MyClass with an attribute diner which is lazilly initialized
MyClass>>diner diner ifNil: [diner := Diner with: self friends]. ^ diner
An intsance of this class is persisted, next outisde of a transaction, I am accessing the diner attribute, thus a Diner instance is created. If I understand correctly this instance will not be persisted. Is it the case?
Hilaire
Hilaire Fernandes a écrit :
Chris Muller a écrit :
Is commit: only to be used when you want to persist an object?
To persist an object, you must use commit.
Ok, related to this question, here is a situation we are use to: lazy initialization.
Now here is the following situation:
Let's MyClass with an attribute diner which is lazilly initialized
MyClass>>diner diner ifNil: [diner := Diner with: self friends]. ^ diner
An intsance of this class is persisted, next outisde of a transaction, I am accessing the diner attribute, thus a Diner instance is created. If I understand correctly this instance will not be persisted. Is it the case?
I can reply myself after a short experimenation, yes it is the case. The Diner instance will not be persisted.
Hilaire
If the Diner is referenced by the persistent graph and you have not set refreshPersistentObjectsEvenWhenChangedOnlyByMe: to true (i.e., leave that false, always), then lazy-initializing the Diner should be fine and it should get persisted; upon your next mySession begin; commit, even if the reference to the Diner made outside the transaction AND another session did not change that object that now references the Diner.
Did you find otherwise? If you post your example maybe it will reveal why..
--- Hilaire Fernandes hilaire2006@laposte.net wrote:
Hilaire Fernandes a �crit :
Chris Muller a �crit :
Is commit: only to be used when you want to persist an object?
To persist an object, you must use commit.
Ok, related to this question, here is a situation we are use to:
lazy
initialization.
Now here is the following situation:
Let's MyClass with an attribute diner which is lazilly initialized
MyClass>>diner diner ifNil: [diner := Diner with: self friends]. ^ diner
An intsance of this class is persisted, next outisde of a
transaction, I
am accessing the diner attribute, thus a Diner instance is
created.
If I understand correctly this instance will not be persisted. Is it the case?
I can reply myself after a short experimenation, yes it is the case. The Diner instance will not be persisted.
Hilaire
Magma mailing list Magma@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/magma
Chris Muller a écrit :
If the Diner is referenced by the persistent graph and you have not set refreshPersistentObjectsEvenWhenChangedOnlyByMe: to true (i.e., leave that false, always), then lazy-initializing the Diner should be fine and it should get persisted; upon your next mySession begin; commit, even if the reference to the Diner made outside the transaction AND another session did not change that object that now references the Diner.
Did you find otherwise? If you post your example maybe it will reveal why..
Oh right!
I closed the connection right after a lazy initialization. In that case the Diner object was not persisted. If before closing I am doing an empty transaction commit: [] it is persisted.
Oh subtle details!
Thanks.
Hilaire
magma@lists.squeakfoundation.org