You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by Xavier <ml...@cstahiti.com> on 2001/07/13 09:00:06 UTC
Different instance of the same object
Hi,
I have some problem with multiple instant of one object in the simple case
----------------------------------------------------------------------------
-
....
Criteria myC = new Criteria();
myC.add(ParentPeer.ID,"1");
Vector aResultList = ParentPeer.doSelect(myC); // myParent is load from db
myParent = (Parent)aResultList.firstElement();
myChild = (Child)myParent.getChilds().get(1); // myChild is load from db
myParent2 = myChild.getParent(); // myParent is load again from db
----------------------------------------------------------------
myParent and myParent2 are different instance!
It's possible to avoid that? it's forecast?
Xa
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org
Re: Different instance of the same object
Posted by John McNally <jm...@collab.net>.
this is a bug. i will fix it when i can get to it, or you can submit a
patch, if you can read the source templates.
basically instead of
collection = FooPeer.doSelect(criteria) in the getFoos(Criteria) method
it should be
tempColl = FooPeer.doSelect
collection = new Vector();
loop over tempColl
addFoo(tempColl.get(i));
end
The template is in turbine's source tree as
conf/torque/templates/om/Object.vm
Note that a decision was made that the Peer system would not be fully
self-consistent as this increases the database activity and OM objects
are generally instantiated with a specific purpose and thrown away
quickly, so self-consistency is not worth it. But that does not hold
for the case you describe.
john mcnally
Xavier wrote:
>
> Hi,
>
> I have some problem with multiple instant of one object in the simple case
> ----------------------------------------------------------------------------
> -
> ....
> Criteria myC = new Criteria();
> myC.add(ParentPeer.ID,"1");
> Vector aResultList = ParentPeer.doSelect(myC); // myParent is load from db
>
> myParent = (Parent)aResultList.firstElement();
>
> myChild = (Child)myParent.getChilds().get(1); // myChild is load from db
>
> myParent2 = myChild.getParent(); // myParent is load again from db
> ----------------------------------------------------------------
>
> myParent and myParent2 are different instance!
> It's possible to avoid that? it's forecast?
>
> Xa
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org
Re: Different instance of the same object
Posted by Leandro Saad <le...@ibnetwork.com.br>.
John McNally wrote:
>
> this is a bug. i will fix it when i can get to it, or you can submit a
> patch, if you can read the source templates.
>
> basically instead of
>
> collection = FooPeer.doSelect(criteria) in the getFoos(Criteria) method
> it should be
>
> tempColl = FooPeer.doSelect
> collection = new Vector();
> loop over tempColl
> addFoo(tempColl.get(i));
> end
>
> The template is in turbine's source tree as
> conf/torque/templates/om/Object.vm
>
> Note that a decision was made that the Peer system would not be fully
> self-consistent as this increases the database activity and OM objects
> are generally instantiated with a specific purpose and thrown away
> quickly, so self-consistency is not worth it. But that does not hold
> for the case you describe.
>
> john mcnally
>
That's why I proposed the creation of BO Managers with configurable
cache support..
__
Leandro Rodrigo Saad Cruz
InterBusiness tecn. e serv.
Sao Paulo - Brasil
Re: Different instance of the same object
Posted by John McNally <jm...@collab.net>.
this is a bug. i will fix it when i can get to it, or you can submit a
patch, if you can read the source templates.
basically instead of
collection = FooPeer.doSelect(criteria) in the getFoos(Criteria) method
it should be
tempColl = FooPeer.doSelect
collection = new Vector();
loop over tempColl
addFoo(tempColl.get(i));
end
The template is in turbine's source tree as
conf/torque/templates/om/Object.vm
Note that a decision was made that the Peer system would not be fully
self-consistent as this increases the database activity and OM objects
are generally instantiated with a specific purpose and thrown away
quickly, so self-consistency is not worth it. But that does not hold
for the case you describe.
john mcnally
Xavier wrote:
>
> Hi,
>
> I have some problem with multiple instant of one object in the simple case
> ----------------------------------------------------------------------------
> -
> ....
> Criteria myC = new Criteria();
> myC.add(ParentPeer.ID,"1");
> Vector aResultList = ParentPeer.doSelect(myC); // myParent is load from db
>
> myParent = (Parent)aResultList.firstElement();
>
> myChild = (Child)myParent.getChilds().get(1); // myChild is load from db
>
> myParent2 = myChild.getParent(); // myParent is load again from db
> ----------------------------------------------------------------
>
> myParent and myParent2 are different instance!
> It's possible to avoid that? it's forecast?
>
> Xa
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org