[SqueakDBX] Should "GlorpSession>>register:" work?

Alan Knight knight at acm.org
Fri Jun 3 22:02:36 UTC 2011


Sorry for chiming in late - it's been a busy week.

In general, one of the invariants in Glorp is that you don't want to mix 
objects between sessions. The proxies remember what session they're 
associated with, and worse, you can end up with duplicate objects in the 
session, and it can be really difficult to debug. So it's definitely 
something to avoid. If you read an object through a session, then you 
want to use it within that same session.

> ------------------------------------------------------------------------
>
> Diogenes Moreira <mailto:diogenes.moreira at gmail.com>
> May 24, 2011 5:20 AM
>
>
> Well, sorry, for the previous mail, because i was answer from my cel 
> phone..
>
> The problem is that:
>
> When you works with a proxy, the proxy collaborators isn`t in the 
> proxy.. the collaborators are in the ObjectTransatcion.. in the 
> UnitOfwork in the Session. And the RealObject Structure and changes is 
> in Mementos dictionary in  ObjectTransatcion.
> In Addition The Proxies has attached the Session..
>
> Yes, you right.. in you previous mail..
>
> but for reattaching you need copy the mementos and proxies 
> collaborators from ObjectTransaction to new Session...
> and change the session from all proxies..
>
> ufff.. too much work.. :) ..
>
> i don't kwon how much cost for refresh object (with the unnecessary DB 
> Read), but in the most of case, is cheaper use the refresh method or 
> maintain live the GlorpSession.
>
> if you want solve this problem.. be my guest.. but i suggest, wait for 
> new GlorpDBX  version (coming soon) and  write first to Alan Knight in 
> core glorp list.. He can give better support than me.
>
> Best
> D.
>
>
> _______________________________________________
> SqueakDBX mailing list
> SqueakDBX at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/mailman/listinfo/squeakdbx
> ------------------------------------------------------------------------
>
> diogenes.moreira at gmail.com <mailto:diogenes.moreira at gmail.com>
> May 20, 2011 10:00 AM
>
>
> You must use GlorpSession>>refresh: anObject to attach anObject to new 
> Session
>
> Best.
> D
> Enviado desde mi BlackBerry® de Claro Argentina
>
> -----Original Message-----
> From: Panu Suominen <panu.j.m.suominen at gmail.com>
> Sender: squeakdbx-bounces at lists.squeakfoundation.org
> Date: Fri, 20 May 2011 10:51:38
> To: The complete and open-source solution to relational database 
> access<squeakdbx at lists.squeakfoundation.org>
> Reply-To: panu.suominen at iki.fi,
> The complete and open-source solution to relational database access
> <squeakdbx at lists.squeakfoundation.org>
> Subject: [SqueakDBX] Should "GlorpSession>>register:" work?
>
> We have problem with reattaching objects to new session.
>
> Following code throws exception telling that connection is not open.
> |person|
> KLDatabase withSession: [:s|
> person := s readOneOf: KLPerson where: [:p| p id = 6127].
> ].
>
> KLDatabase withSession: [:s|
> s inUnitOfWorkDo: [
> self halt.
> s register: person.
> Transcript show: person parameters.
> ]
> ].
>
> The problem seems to be that "GlorpSession>>register:" does not check
> if there is an Glorp proxy inside the object being registered.
> Tutorial (http://www.eli.sdsu.edu/SmalltalkDocs/GlorpTutorial.pdf)
> states that it should reattach any nested objects (proxies) too but it
> does not.
>
> Is this known problem or am I doing something wrong? I can try to fix
> this if this is an actual bug. Of course using refresh:
> one can avoid this problem but it causes unnecessary database reads to 
> occur.
>
>
> _______________________________________________
> SqueakDBX mailing list
> SqueakDBX at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/mailman/listinfo/squeakdbx
> ------------------------------------------------------------------------
>
> Panu Suominen <mailto:panu.j.m.suominen at gmail.com>
> May 20, 2011 3:51 AM
>
>
> We have problem with reattaching objects to new session.
>
> Following code throws exception telling that connection is not open.
> |person|
> KLDatabase withSession: [:s|
> person := s readOneOf: KLPerson where: [:p| p id = 6127].
> ].
>
> KLDatabase withSession: [:s|
> s inUnitOfWorkDo: [
> self halt.
> s register: person.
> Transcript show: person parameters.
> ]
> ].
>
> The problem seems to be that "GlorpSession>>register:" does not check
> if there is an Glorp proxy inside the object being registered.
> Tutorial (http://www.eli.sdsu.edu/SmalltalkDocs/GlorpTutorial.pdf)
> states that it should reattach any nested objects (proxies) too but it
> does not.
>
> Is this known problem or am I doing something wrong? I can try to fix
> this if this is an actual bug. Of course using refresh:
> one can avoid this problem but it causes unnecessary database reads to 
> occur.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeakdbx/attachments/20110603/7237b7cd/attachment.htm


More information about the SqueakDBX mailing list