Hi,
I'm having an issue with elements added to a collection that is part of an exclusive mapping that are always deleted. I have a GwTournament that has a collection of aGwTournamentCategory, but when I add a category to this collection, at the moment of committing the unit of work the row is marked for deletion. Getting into `UnitOfWork>>computeCollectionDeletesFor: aMapping inObject: anObject` I notice that the memento and the object memento are the same object, and so is the the value read using the mapping. This causes all elements to be removed when the UOW is committed, I don't know why this is so. aDescriptor toManyMapping attributeName: #categories; referenceClass: GwTournamentCategory; collectionType: SortedCollection; orderBy: [ :each | (each getTable: 'GWTOURNAMENTCATEGORY') getField: 'position' ]; beExclusive; join: (Join from: (table fieldNamed: 'id') to: ((self tableNamed: 'GWTOURNAMENTCATEGORY') fieldNamed: 'tournament_id')). If I remove the "beExclusive" then this doesn't happen anymore but it causes the opposite situation: for some reason the elements are removed from the collection, but never deleted from the DB, and new elements are added each time. Regards! 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/CAJMgPCJ-9dPsqLa2yW4-iGzjk%3DNKQWkPPeBbHmKKJ%3DL_fXf1tA%40mail.gmail.com. |
Hi,
Answering myself, I noticed that in Pharo's SortedCollection, the elements are inside another collection, so a #removeAll replaces this internal collection by another, empty, one. For some reason this might mess with something, but replacing the collection to be an OrderedCollection solved the issue. Regards! Esteban A. Maringolo On Wed, Nov 18, 2020 at 1:01 PM Esteban Maringolo <[hidden email]> wrote: > > Hi, > > I'm having an issue with elements added to a collection that is part > of an exclusive mapping that are always deleted. > > I have a GwTournament that has a collection of aGwTournamentCategory, > but when I add a category to this collection, at the moment of > committing the unit of work the row is marked for deletion. > > Getting into `UnitOfWork>>computeCollectionDeletesFor: aMapping > inObject: anObject` I notice that the memento and the object memento > are the same object, and so is the the value read using the mapping. > > This causes all elements to be removed when the UOW is committed, I > don't know why this is so. > > aDescriptor toManyMapping > attributeName: #categories; > referenceClass: GwTournamentCategory; > collectionType: SortedCollection; > orderBy: [ :each | (each getTable: 'GWTOURNAMENTCATEGORY') getField: > 'position' ]; > beExclusive; > join: > (Join > from: (table fieldNamed: 'id') > to: ((self tableNamed: 'GWTOURNAMENTCATEGORY') fieldNamed: > 'tournament_id')). > > If I remove the "beExclusive" then this doesn't happen anymore but it > causes the opposite situation: for some reason the elements are > removed from the collection, but never deleted from the DB, and new > elements are added each time. > > Regards! > > 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/CAJMgPC%2BU-B-vHuBMzEbx7Awf0X7swKd5YmkbT5_nCj3hJ5xR-w%40mail.gmail.com. |
Ah, that makes sense. There's dialect-specific code to deal with different collection representations, but it probably never got done for Pharo SortedCollection. On Wed, Nov 18, 2020 at 11:29 AM Esteban Maringolo <[hidden email]> wrote: Hi, 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/CAGWHZ9_R8OsvdW-DoBvq430YG%2BRnuZ9O3y0E8ed8VuiY_gHqXw%40mail.gmail.com. |
Free forum by Nabble | Edit this page |