Login  Register

Re: Voyage: Circular references

Posted by EstebanLM on Jul 29, 2013; 12:55pm
URL: https://forum.world.st/Voyage-Circular-references-tp4691940p4701282.html

Hi Sabine, 

I'm really sorry, I just went on vacations when you sent this mail :(

Is this problem persisting? 
Did you reach a solution?
Can I help you with something?

Esteban


On Jul 19, 2013, at 12:56 PM, Sabine Knöfel <[hidden email]> wrote:

Hi Esteban,

thanks!

I think the solution of Bernat will not be enough for me.
I added the class methods isVoyageRoot to the root objects (like trip,
country and so on).

But I have instances which should never be persistent, e.g. the
country I mentioned. The Country has currencies and expense rates and
this is a lot of stuff...this should be only transient in the image.

The transient country is referenced by persistent instances of trip.
(countrie does naturally not point to trips)

Trip (persistant) -> Country (transient)

If I try to save a trip, voyage at some point enters
>>rawReference: description:
and there, it looks whether anObject (a country) isNew:
isNew means the other object, the country has an _id (mongo id).

The country does not have an id and for this reason, voyage tries to
make it persistent although its class has isVogageRoot false.
And than the system enters a point where it tries to make so many
objects persistent that the image does not respond anymore.

So, my question is: is it possible to define
"In class trip, there is an inst var country -> voyage please save
only a symbol here"
and
"voyage, if loading a trip, for inst var country, do shting"

Sure, I could save symbols within the trips country inst var all the time
and get the country it if needed, but it would be nicer if voyage coud
do that for me .-)

Sabine





On Fri, Jul 19, 2013 at 11:52 AM, EstebanLM [via Smalltalk]
<<a href="x-msg://4592/user/SendEmail.jtp?type=node&amp;node=4699517&amp;i=0" target="_top" rel="nofollow" link="external">[hidden email]> wrote:

> Hi Sabine,
>
> If Bernat help is not enough, I would like to have some more insight on your
> problem, so If you can put here a better description of your model and the
> problem you are having, I will have a look :)
>
> Esteban
>
> On Jul 19, 2013, at 10:42 AM, Bernat Romagosa <[hidden email]> wrote:
>
> Hi Sabine!
>
> If you want an object to be referenced by another, and not embedded in it,
> you need to give that object root entity. As a root, the object will have a
> collection of its own, and will be referenced by other objects by id. If the
> object is not root, it will be embedded inside the referring object as a
> property.
>
> So, to be safe, always set #isVoyageRoot to return true at class side of all
> objects you don't want to have embedded. In general, "big enough" objects
> who are referenced by different objects should be root.
>
> In my case, I had a centre which had users which had centres. Users also had
> projects, and projects also had users. Big mess, I know. Besides that, all
> users, centres and projects had profiles. My solution was to make centres,
> projects and users be roots, and let only the profiles be embedded.
>
> I hope this helped!
>
> Bernat.
>
>
> 2013/7/19 Sabine Knöfel <[hidden email]>
>>
>> Hi Esteban,
>>
>> yes, now the Rectangle Example works after doing the reset.
>>
>> But saving my model still leads to a non responding image because
>> Voyage is trying to write json for all model stuf deep deep deep and
>> circular. Perhaps same like:
>> http://forum.world.st/Voyage-Circular-references-td4691940.html#a4699436
>>
>> I dont know anything about Magritte (yet) and I need a hint what to
>> define in my model so that it stops creating json at certain points
>> and creates only e.g. a Symbol.
>>
>> Example: My model instance  of trip has a connection to an instance of
>> country. The country should not be written in json with all its
>> definitions. Voyage should only write e.g. #germany in the json and
>> later, when getting the instance back from the database, I want to
>> reassign the trip to the country.
>>
>> I already implemented this stuff when working witk Mongotalk the last
>> months and it worked fine. But my question yesterday:
>>
>> http://forum.world.st/MongoDB-open-close-in-production-singleton-or-not-td4699322.html
>> lead to my impression that I should use voyage.
>>
>> So, how can I define the "borders"?
>>
>> Sabine
>>
>> On Thu, Jul 18, 2013 at 7:45 PM, EstebanLM [via Smalltalk]
>> <[hidden email]> wrote:
>>
>> > Hi Sabine,
>> >
>> > Probably you do not missed anything.
>> > Probably I missed to update the voyage configuration :)
>> >
>> > can you try doing
>> >
>> > VOMongoRepository allInstancesDo: #reset.
>> >
>> > before trying again?
>> >
>> > Cheers,
>> > Esteban
>> >
>> > On Jul 18, 2013, at 6:31 PM, Sabine Knöfel <[hidden email]> wrote:
>>
>> >
>> >> I found this:
>> >> http://smallworks.eu/web/blog/2013-06-14-voyage-the-adventure
>> >>
>> >> Chapter "Enhancing storage"
>> >> But if I add the 3+1 methods to Rectangle, and save it again, the json
>> >> did
>> >> not change.
>> >>
>> >> Did I miss something?
>> >>
>> >>
>> >>
>> >>
>> >> --
>> >> View this message in context:
>> >> http://forum.world.st/Voyage-Circular-references-tp4691940p4699436.html
>> >> Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
>> >>
>> >
>> >
>> >
>> >
>> > ________________________________
>> > If you reply to this email, your message will be added to the discussion
>> > below:
>> > http://forum.world.st/Voyage-Circular-references-tp4691940p4699443.html
>> > To unsubscribe from Voyage: Circular references, click here.
>> > NAML
>>
>> ________________________________
>> View this message in context: Re: Voyage: Circular references
>>
>> Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
>
>
>
>
> --
> Bernat Romagosa.
>
>
>
>
> ________________________________
> If you reply to this email, your message will be added to the discussion
> below:
> http://forum.world.st/Voyage-Circular-references-tp4691940p4699516.html
> To unsubscribe from Voyage: Circular references, click here.
> NAML


View this message in context: Re: Voyage: Circular references
Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.