Hi Sabine, I'll check, but you shouldn't have that problem, so is probably a bug :)
Esteban On Mon, Dec 2, 2013 at 12:51 PM, Sabine Knöfel <sabine.knoe...@gmail.com>wrote: > Hi Esteban, > > I found a problem in mongo/voyage and I have reduced and extracted it for > repro. > I ask for your opinion if this is a bug. > > If you file in the code below, the method >>testDemo creates a simple > model: > Paper has 1:1 reference to Planet. > Paper has 1:1 reference to Star. > Star has 1:N reference to Planet. > Star has 1:1 reference to Paper. > Planet has 1:1 reference to Paper. > > If you run >>testDemo, you see that the model which was created is ok with > all its references. > (self assert: thePaper planet = thePaper star planets first.) ==> ok > > If you reset the repository and load Paper from database with > Paper select all > and make the same check, the references are lost. > > VORepository current reset. > theReloadedPaper := Paper selectAll first. > self assert: theReloadedPaper planet = theReloadedPaper star planets first > ==>not ok > > But if you remove the comment within >>mongoPlanets > which leads to sending a message to the newly loaded object, then it works. > > write: [ :star :planets | star planets: (planets "select: [:each | each > someMethod]") ]); > > Do I have to send a message to each of the instances after loading? I think > no. > > If I did not understand correctly how to use voyage, please tell me. > > Regards > Sabine > > > > > Object subclass: #Planet > instanceVariableNames: 'planetname star paper' > classVariableNames: '' > poolDictionaries: '' > category: 'RKA24-Demo'! > > !Planet methodsFor: 'accessing' stamp: 'sabineknoefel 12/2/2013 12:05'! > paper > ^ paper! ! > > !Planet methodsFor: 'accessing' stamp: 'sabineknoefel 12/2/2013 12:05'! > paper: anObject > paper := anObject! ! > > !Planet methodsFor: 'accessing' stamp: 'sabineknoefel 7/18/2013 16:17'! > planetname > ^ planetname! ! > > !Planet methodsFor: 'accessing' stamp: 'sabineknoefel 7/18/2013 16:17'! > planetname: anObject > planetname := anObject! ! > > !Planet methodsFor: 'accessing' stamp: 'sabineknoefel 12/2/2013 11:53'! > star > ^ star! ! > > !Planet methodsFor: 'accessing' stamp: 'sabineknoefel 12/2/2013 11:53'! > star: anObject > star := anObject! ! > > > !Planet methodsFor: 'testing' stamp: 'sabineknoefel 12/2/2013 12:25'! > someMethod > ^true! ! > > "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "! > > Planet class > instanceVariableNames: ''! > > !Planet class methodsFor: 'as yet unclassified' stamp: 'sabineknoefel > 7/18/2013 16:16'! > isVoyageRoot > ^true! ! > > !Planet class methodsFor: 'as yet unclassified' stamp: 'sabineknoefel > 12/2/2013 12:23'! > mongoStar > <mongoDescription> > ^ VOMongoToOneDescription new > attributeName: 'star'; > kind: Star; > accessor: (MAPluggableAccessor read: [ :planet | planet > star ] write: [ > :planet :star | planet star: star ]); > yourself! ! > > !Planet class methodsFor: 'as yet unclassified' stamp: 'sabineknoefel > 12/2/2013 12:30'! > testDemo > "self testDemo" > > | thePlanet theStar thePaper theReloadedPaper | > "create simple model" > thePaper := Paper new theme: 'a paper about 42'. > thePlanet := Planet new planetname: 'Orion'; paper: thePaper. > theStar := Star new starname: 'Betelgeuse'; paper: thePaper. > theStar addPlanet: thePlanet. > thePaper star: theStar. > thePaper planet: thePlanet. > thePaper save. > > "check references - ok" > self assert: thePaper planet = thePaper star planets first. > > VORepository current reset. > theReloadedPaper := Paper selectAll first. > "references are lost now" > self assert: theReloadedPaper planet = theReloadedPaper star > planets first! > ! > > > Object subclass: #Star > instanceVariableNames: 'starname planets paper' > classVariableNames: '' > poolDictionaries: '' > category: 'RKA24-Demo'! > > !Star methodsFor: 'api' stamp: 'sabineknoefel 7/18/2013 16:21'! > addPlanet: aPlanet > self planets add: aPlanet. > aPlanet star: self! ! > > > !Star methodsFor: 'accessing' stamp: 'sabineknoefel 12/2/2013 12:05'! > paper > ^ paper! ! > > !Star methodsFor: 'accessing' stamp: 'sabineknoefel 12/2/2013 12:05'! > paper: anObject > paper := anObject! ! > > !Star methodsFor: 'accessing' stamp: 'sabineknoefel 7/18/2013 16:20'! > planets > planets ifNil: [ self planets: OrderedCollection new ]. > ^ planets! ! > > !Star methodsFor: 'accessing' stamp: 'sabineknoefel 7/18/2013 16:20'! > planets: anObject > planets := anObject! ! > > !Star methodsFor: 'accessing' stamp: 'sabineknoefel 7/18/2013 16:18'! > starname > ^ starname! ! > > !Star methodsFor: 'accessing' stamp: 'sabineknoefel 7/18/2013 16:18'! > starname: anObject > starname := anObject! ! > > "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "! > > Star class > instanceVariableNames: ''! > > !Star class methodsFor: 'as yet unclassified' stamp: 'sabineknoefel > 7/18/2013 16:16'! > isVoyageRoot > ^true! ! > > !Star class methodsFor: 'as yet unclassified' stamp: 'sabineknoefel > 12/2/2013 12:31'! > mongoPlanets > "remove comment below then references are not lost anymore" > > <mongoDescription> > ^ VOMongoToManyDescription new > attributeName: 'planets'; > kind: Planet; > accessor: > (MAPluggableAccessor > read: [ :star | star > planets ] > write: [ :star :planets | > star planets: (planets "select: [:each | > each someMethod]") ]); > yourself ! ! > > > Object subclass: #Paper > instanceVariableNames: 'star planet theme' > classVariableNames: '' > poolDictionaries: '' > category: 'RKA24-Demo'! > > !Paper methodsFor: 'accessing' stamp: 'sabineknoefel 12/2/2013 11:54'! > planet > > ^ planet! ! > > !Paper methodsFor: 'accessing' stamp: 'sabineknoefel 12/2/2013 11:54'! > planet: anObject > > planet := anObject! ! > > !Paper methodsFor: 'accessing' stamp: 'sabineknoefel 12/2/2013 11:54'! > star > > ^ star! ! > > !Paper methodsFor: 'accessing' stamp: 'sabineknoefel 12/2/2013 11:54'! > star: anObject > > star := anObject! ! > > !Paper methodsFor: 'accessing' stamp: 'sabineknoefel 12/2/2013 11:54'! > theme > > ^ theme! ! > > !Paper methodsFor: 'accessing' stamp: 'sabineknoefel 12/2/2013 11:54'! > theme: anObject > > theme := anObject! ! > > "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "! > > Paper class > instanceVariableNames: ''! > > !Paper class methodsFor: 'as yet unclassified' stamp: 'sabineknoefel > 12/2/2013 11:48'! > isVoyageRoot > ^true! ! > > !Paper class methodsFor: 'as yet unclassified' stamp: 'sabineknoefel > 12/2/2013 12:23'! > mongoPlanet > <mongoDescription> > ^ VOMongoToOneDescription new > attributeName: 'planet'; > accessor: (MAPluggableAccessor > read: [ :paper | paper planet ] > write: [ :paper :planet | paper planet: planet ]); > yourself! ! > > !Paper class methodsFor: 'as yet unclassified' stamp: 'sabineknoefel > 12/2/2013 12:23'! > mongoStar > <mongoDescription> > ^ VOMongoToOneDescription new > attributeName: 'star'; > accessor: (MAPluggableAccessor > read: [ :paper | paper star ] > write: [ :paper :star | paper star: star ]); > yourself! ! > > > > > -- > View this message in context: > http://forum.world.st/Mongo-lost-references-bug-tp4726673.html > Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com. > >