You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Daniel Perry <d....@netcase.co.uk> on 2004/12/08 11:46:34 UTC

Criteria through extent (Was: Circular criteria)

It apprears that ojb doesnt like criteria at depths that go beyond an
extent.

My criteria is:
crit.addEqualTo("behaviourId", new Integer(id));
crit.addLessThan("rating", new Integer(1));
crit.addEqualTo("meeting.pdp.createdBy", new Integer(mid));

And this generates the following sql (shortened!):

SELECT ... FROM behaviourrating A0 INNER JOIN appraisal A1 ON
A0.meetingId=A1.id WHERE ((A0.behaviourId = '21') AND A0.rating < '1') AND
createdBy = '7'

As you can see, it generates the rating and behaviourId where clauses
properly.  But the third clause doesnt work.

The table appraisal is an extent of meeting.
behaviourRating.meeting points to a Meeting, not an appraisal.  At the
moment there is only one extent of meeting, but that will change in future,
so ditching meeting isnt an option.

Meeting doesnt have a reference to pdp, but appraisal does.

Should ojb handle this criteria? or should it say that as meeting doesnt
have a 'pdp.createdBy' defined, it will ignore it, even though all the
instanciable subclasses (Appraisal) do have!  This would seem fair enough,
although a little annoying!

Could i add a reference (and associated id) for pdp, and employee to
Meeting, but still keep all subclasses in separate tables?

Thanks,

Daniel.


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


RE: Criteria through extent (Was: Circular criteria)

Posted by Daniel Perry <d....@netcase.co.uk>.
> when resolving the path meeting.pdp.createdBy ojb looks for a
> collection- or
> reference-descriptor called 'meeting' and it uses the referenced
> class to reolve
> further path-segements 'pdp....'. so if the class referenced by
> 'meeting' does
> not have a reference-descriptor named 'pdp' ojb is not able to
> resolve this
> reference.

So it doesnt automatically look for extent classes that have that property.
Initially it seemed to me that it ought to do this for you, but fair enough
though, as i guess there would be no 'right answer' if only some extents
have the field.

>
> there a two solutions right now:
> 1.) define a reference-descriptor named 'pdp' in your top-class (meeting)

Ok, but do i also need to define a fk field: pdpId? or can i leave that in
the extents?  If i have to define the field, do i have to create a database
table for Meeting, or can that remain  in the extents?

> 2.) use Criteri#addPathClass('pdp',Appraisal.class) as a hint

crit.addPathClass("meeting",Appraisal.class);

This works beautifully.  I get the expected SQL.  From the docs it suggests
that it will only look at the classes i hint, so other classes that extend
Meeting will be ignored.  Is this right?  This adds a desirable side effect,
as for these reports i am only interested in elements linked to an
Appraisal, no other extents.

For future reference, if i was specifying a deeper class (say Pdp) would i
use the path "meeting.pdp" or just "pdp"?

>
> hth
> jakob

Helped a LOT!!!!! Now i dont have to load thousands of useless records and
filter them with 'if' statements!

Thanks,

Daniel.


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: Criteria through extent (Was: Circular criteria)

Posted by Jakob Braeuchi <jb...@gmx.ch>.
hi daniel,

when resolving the path meeting.pdp.createdBy ojb looks for a collection- or 
reference-descriptor called 'meeting' and it uses the referenced class to reolve 
further path-segements 'pdp....'. so if the class referenced by 'meeting' does 
not have a reference-descriptor named 'pdp' ojb is not able to resolve this 
reference.

there a two solutions right now:
1.) define a reference-descriptor named 'pdp' in your top-class (meeting)
2.) use Criteri#addPathClass('pdp',Appraisal.class) as a hint

hth
jakob

Daniel Perry schrieb:

> It apprears that ojb doesnt like criteria at depths that go beyond an
> extent.
> 
> My criteria is:
> crit.addEqualTo("behaviourId", new Integer(id));
> crit.addLessThan("rating", new Integer(1));
> crit.addEqualTo("meeting.pdp.createdBy", new Integer(mid));
> 
> And this generates the following sql (shortened!):
> 
> SELECT ... FROM behaviourrating A0 INNER JOIN appraisal A1 ON
> A0.meetingId=A1.id WHERE ((A0.behaviourId = '21') AND A0.rating < '1') AND
> createdBy = '7'
> 
> As you can see, it generates the rating and behaviourId where clauses
> properly.  But the third clause doesnt work.
> 
> The table appraisal is an extent of meeting.
> behaviourRating.meeting points to a Meeting, not an appraisal.  At the
> moment there is only one extent of meeting, but that will change in future,
> so ditching meeting isnt an option.
> 
> Meeting doesnt have a reference to pdp, but appraisal does.
> 
> Should ojb handle this criteria? or should it say that as meeting doesnt
> have a 'pdp.createdBy' defined, it will ignore it, even though all the
> instanciable subclasses (Appraisal) do have!  This would seem fair enough,
> although a little annoying!
> 
> Could i add a reference (and associated id) for pdp, and employee to
> Meeting, but still keep all subclasses in separate tables?
> 
> Thanks,
> 
> Daniel.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org