Posted by
Esteban A. Maringolo on
Nov 23, 2020; 10:26pm
URL: https://forum.world.st/Registration-of-basic-objects-after-retrieve-tp5124909.html
Hi,
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.
E.g.
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
register:"
| 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
--
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
[hidden email].
To view this discussion on the web visit
https://groups.google.com/d/msgid/glorp-group/CAJMgPCKpg3OGZuwU84kTnOJc2b75C8HgESvb7H_E0U2cNW5q2Q%40mail.gmail.com.