Registration of basic objects after retrieve:

Skip to first unread message

Esteban Maringolo

Nov 23, 2020, 5:27:16 PM11/23/20
to GLORP Mailing List

I was getting some issues with objects lazily initialized that forced
a read during the commit phase, triggering an exception.

Since I couldn't fix that, I did a little modification of the
architecture to delegate that lazily initialized collection to another
component, and then the issue happened again, to simplify it and make
it even faster, I performed a simple retrieve to fetch just one value
from the DB.

query := SimpleQuery
readOneOf: GwPlayerHandicap
where: [ :each | each player = aGwPlayer AND: [ each date <= aDate ] ].
query orderBy: [ :each | each date descending ].
query retrieve: [ :each | each value ].

The weird thing is that when retrieve that single value (an Integer in
this case) it attempts to register in vía `privateRegisterAsOld:
anObject`, which IMO is meaningless, since such an object won't be
mapped to the database in any way.

GlorpSession>>privateRegisterAsOld: anObject
"Register the object as something we already read from the database,
skipping the isNew: test. Private! Normally you would just use
| realObject |
currentUnitOfWork isNil ifTrue: [^self].
realObject := self realObjectFor: anObject ifNone: [^self].
currentUnitOfWork register: realObject

I added a break condition before that, in this case for two simple
value objects and this solved the issue:

GlorpSession>>privateRegisterAsOld: anObject
| realObject |
currentUnitOfWork isNil ifTrue: [^self].
realObject := self realObjectFor: anObject ifNone: [^self].
(realObject isString or: [ realObject isNumber ]) ifTrue: [ ^self ].
currentUnitOfWork register: realObject

Am I missing something here?

Esteban A. Maringolo

Alan Knight

Nov 23, 2020, 9:03:51 PM11/23/20
I think the right test is that if the object doesn't have a descriptor you skip it. But I'd kind of expect register to do that anyway.

Also with the initial issue, you might be able to map the field or otherwise bypass the lazy initialization so the first issue doesn't happen.

You received this message because you are subscribed to the Google Groups "glorp-group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web visit
Reply all
Reply to author
0 new messages