You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cayenne.apache.org by Tore Halset <ha...@pvv.ntnu.no> on 2008/09/03 13:58:56 UTC
ToOne Fault
Hello.
I have a toOne relationship A->B. Both A and B use the same multi-
column primary key. All Bs are already in the DataRowStore.
DataObjectUtils.objectForPK() on any of the Bs work fine with no
queries to the database.
If I create a new DataContext and fetch in some As and issue a.getB(),
then a query is run on the database. Why not look in the DataRowStore
first?
I have debugged this and found some interesting stuff in
DataDomainQueryAction to handle RelationshipQuery around line 188.
// check if we can derive target PK from FK... this
implies that the
// relationship is to-one
if (relationship.isSourceIndependentFromTargetChange()) {
return !DONE;
}
The thing that makes this return is
ObjRelationship.isToDependentEntity() that returnes true. Why does
this have to force us to requery the toOne relationship? Any way
around this?
This is happening on trunk, M4 and M3
Regards,
- Tore.
Re: ToOne Fault
Posted by Andrus Adamchik <an...@objectstyle.org>.
I don't have the idea yet on how to solve it, but from my experience
calls to 'isSourceIndependentFromTargetChange' throughout the code are
causing a number of subtle bugs with relationships based on multi-
column PK's... Been affected by this more than once myself :-/
Andrus
On Sep 3, 2008, at 2:58 PM, Tore Halset wrote:
> Hello.
>
> I have a toOne relationship A->B. Both A and B use the same multi-
> column primary key. All Bs are already in the DataRowStore.
> DataObjectUtils.objectForPK() on any of the Bs work fine with no
> queries to the database.
>
> If I create a new DataContext and fetch in some As and issue
> a.getB(), then a query is run on the database. Why not look in the
> DataRowStore first?
>
> I have debugged this and found some interesting stuff in
> DataDomainQueryAction to handle RelationshipQuery around line 188.
>
> // check if we can derive target PK from FK... this
> implies that the
> // relationship is to-one
> if (relationship.isSourceIndependentFromTargetChange()) {
> return !DONE;
> }
>
> The thing that makes this return is
> ObjRelationship.isToDependentEntity() that returnes true. Why does
> this have to force us to requery the toOne relationship? Any way
> around this?
>
> This is happening on trunk, M4 and M3
>
> Regards,
> - Tore.
>