ToManyMapping saving instances twice

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

ToManyMapping saving instances twice

Esteban A. Maringolo
I'm importing a lot of objects from a plain text file, and for some reason I don't understand I'm getting the #items item of my parent object inserted twice.

I have the class Route that has many RouteItems.  

The importer code got somewhat convoluted, but basically what it does is:

glorpSession inUnitOfWorkDo: [:session |
       [ stream atEnd ] whileFalse: [
              route := Route new.
              session register: route
              route addItem: RouteItem new.
       ]      
].

If I run a simplified version of the above code, it works ok. So the mappings are fine.

Something like:

glorpSession inUnitOfWorkDo: [ :session |
| route |
route := Route new.
session register: route.
route addItem: RouteItem new.
session register: route.
route := Route new.
session register: route.
route  addItem: RouteItem new.
]


I can't understand what is causing the duplication of inserts in my "real" code.

Any clues?


Best regards,








--
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 post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/glorp-group.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: ToManyMapping saving instances twice

Esteban A. Maringolo
Nevermind... it was my mistake.


http://i.imgur.com/nvHCfC8.gif?1
Esteban A. Maringolo


2014-05-18 20:36 GMT-03:00 Esteban A. Maringolo <[hidden email]>:

> I'm importing a lot of objects from a plain text file, and for some reason I
> don't understand I'm getting the #items item of my parent object inserted
> twice.
>
> I have the class Route that has many RouteItems.
>
> The importer code got somewhat convoluted, but basically what it does is:
>
> glorpSession inUnitOfWorkDo: [:session |
>        [ stream atEnd ] whileFalse: [
>               route := Route new.
>               session register: route
>               route addItem: RouteItem new.
>        ]
> ].
>
> If I run a simplified version of the above code, it works ok. So the
> mappings are fine.
>
> Something like:
>
> glorpSession inUnitOfWorkDo: [ :session |
> | route |
> route := Route new.
> session register: route.
> route addItem: RouteItem new.
> session register: route.
> route := Route new.
> session register: route.
> route  addItem: RouteItem new.
> ]
>
>
> I can't understand what is causing the duplication of inserts in my "real"
> code.
>
> Any clues?
>
>
> Best regards,
>
>
>
>
>
>
>
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "glorp-group" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/glorp-group/TxBRpfcur5k/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [hidden email].
> To post to this group, send email to [hidden email].
> Visit this group at http://groups.google.com/group/glorp-group.
> For more options, visit https://groups.google.com/d/optout.

--
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 post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/glorp-group.
For more options, visit https://groups.google.com/d/optout.