You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Bruno René Santos <br...@holos.pt> on 2012/03/30 18:06:59 UTC

DataContexts mixed

Hello all,

I am using now Cayenne 3.1M4 Snapshot and first let me just say that its
performance is much better than 3.0.1 (How did you do it? just curious) but
I am having a strange problem.

I am creating a web application with popups as item details where I use
child contexts in order to able to rollback changes on these popups without
ruining the level below the popup. One of the quirks we have, by client
request, is that any commit changes on any popup saves directly to the DB
but we still need to mantain the local roolback on each popup.

The problem that I am getting is that when I create a Item A on a popup
that has  connection to items B and C. But when I try to call A.getBArray()
I get B's from the current context and B's from the the past context of the
popup where I created A.... Everything get doubled! For now I overrode
readProperty and filter any item that has the objectcontext different from
the current context but I would like to know how to solve this without
using this kind of 'subterfuges'.

Regards
Bruno Santos

-- 
Bruno René Santos | brunorene@holos.pt | Gestor de Projectos | Analista |
Programador | Investigador

Holos - Soluções Avançadas em Tecnologias de Informação S.A.
Parque de Ciência e Tecnologia de Almada/Setúbal . Edifício Madan Parque
Rua dos Inventores . Quinta da Torre . 2825 - 182 Caparica . Portugal
Phone: +351 210 438 686 . Fax: +351 210 438 687 . Web: www.holos.pt

This email and any files transmitted with it are confidential and intended
solely for the use of the individual or entity to whom they are addressed.
If you are not the intended recipient or the person responsible for
delivering the email to the intended recipient, be advised that you have
received this email in error and that any use, dissemination, forwarding,
printing, or copying of this email is strictly prohibited. If you have
received this email in error please notify Bruno René Santos by telephone
on +351 210 438 686

Re: DataContexts mixed

Posted by Bruno René Santos <br...@holos.pt>.
Hello Aristedes,

I have just found out the problem.... I had two DataObjects, one inherited
from other but with no other difference. So Cayenne got confused and gave
me versions of the same object on the Parent object and also in the Child
Object on different contexts. The child was from the context I have just
committed (the child one) the parent was on the current context. So when I
defined a qualifier for the child, really differentianting from the parent,
everything was resolved.

Regards
Bruno

On Sat, Mar 31, 2012 at 2:19 AM, Aristedes Maniatis <ar...@maniatis.org>wrote:

> On 31/03/12 3:06 AM, Bruno René Santos wrote:
>
>> Hello all,
>>
>> I am using now Cayenne 3.1M4 Snapshot and first let me just say that its
>> performance is much better than 3.0.1 (How did you do it? just curious)
>> but
>> I am having a strange problem.
>>
>> I am creating a web application with popups as item details where I use
>> child contexts in order to able to rollback changes on these popups
>> without
>> ruining the level below the popup. One of the quirks we have, by client
>> request, is that any commit changes on any popup saves directly to the DB
>> but we still need to mantain the local roolback on each popup.
>>
>
> I suspect that Cayenne child nested contexts are not what you want to be
> using there. You probably just want another plain vanilla context, but once
> you commit you might want to copy any objects you just committed into the
> "parent" context (if they are referred to there).
>
> I can see that your code is going to get very messy if the "parent" object
> is new and not yet committed to the database, but you open the popup and
> want to commit those to the database with a join to the parent. Ugh.
>
> Ari
>
>
> --
> -------------------------->
> Aristedes Maniatis
> GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A
>
>


-- 
Bruno René Santos | brunorene@holos.pt | Gestor de Projectos | Analista |
Programador | Investigador

Holos - Soluções Avançadas em Tecnologias de Informação S.A.
Parque de Ciência e Tecnologia de Almada/Setúbal . Edifício Madan Parque
Rua dos Inventores . Quinta da Torre . 2825 - 182 Caparica . Portugal
Phone: +351 210 438 686 . Fax: +351 210 438 687 . Web: www.holos.pt

This email and any files transmitted with it are confidential and intended
solely for the use of the individual or entity to whom they are addressed.
If you are not the intended recipient or the person responsible for
delivering the email to the intended recipient, be advised that you have
received this email in error and that any use, dissemination, forwarding,
printing, or copying of this email is strictly prohibited. If you have
received this email in error please notify Bruno René Santos by telephone
on +351 210 438 686

Re: DataContexts mixed

Posted by Aristedes Maniatis <ar...@maniatis.org>.
On 31/03/12 3:06 AM, Bruno René Santos wrote:
> Hello all,
>
> I am using now Cayenne 3.1M4 Snapshot and first let me just say that its
> performance is much better than 3.0.1 (How did you do it? just curious) but
> I am having a strange problem.
>
> I am creating a web application with popups as item details where I use
> child contexts in order to able to rollback changes on these popups without
> ruining the level below the popup. One of the quirks we have, by client
> request, is that any commit changes on any popup saves directly to the DB
> but we still need to mantain the local roolback on each popup.

I suspect that Cayenne child nested contexts are not what you want to be using there. You probably just want another plain vanilla context, but once you commit you might want to copy any objects you just committed into the "parent" context (if they are referred to there).

I can see that your code is going to get very messy if the "parent" object is new and not yet committed to the database, but you open the popup and want to commit those to the database with a join to the parent. Ugh.

Ari


-- 
-------------------------->
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A