You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by jerome moliere <je...@gmail.com> on 2007/04/16 13:50:12 UTC

Querymetadata

Hi all,
playing around with cayenne, I'd like to set fetching limits and page sizes
for my queries,
this seems to be done through QueryMetadata , but this interface does not
provide any setter ..
So I'd like to know the proper way for forging its own metadata to be passed
to the Query to be run...
I've seen a BaseMutableQueryMetadata class, but I guess I should not be
obliged to make some uggly donwcasts, isn't it ?

Is there a way to hook in the Cayenne queries generation mechanism to
configure the QueryMetaData to be used with my own settings ?
Did'nt see this, but I may be blind -)
Thanks for your help
cheers
jerome
-- 
Jerome Moliere - Mentor/J
http://romjethoughts.blogspot.com/
auteur Eyrolles

Re: Querymetadata

Posted by Andrus Adamchik <an...@objectstyle.org>.
On Apr 16, 2007, at 5:02 PM, jerome moliere wrote:

> Once again I think that your answer is perfect.... It's just a  
> refactoring
> of the code I planned to put in place...

Great! I wasn't sure I answered your question the first time :-)

Andrus


Re: Querymetadata

Posted by jerome moliere <je...@gmail.com>.
2007/4/16, Andrus Adamchik <an...@objectstyle.org>:
>
>
> On Apr 16, 2007, at 3:28 PM, jerome moliere wrote:
>
> > thanks for the reply andrus...
> > so rather than imaginating factories with named  configuration
> > parameters
> > (metadata) I'd  put in place  named  queries  carrying the
> > configuration ?
> > Why not.....
>
> Jerome,
>
> As it happened in the past a few times, I suspect I don't fully
> understand what you are trying to do. Use a standard query? Build a
> custom query? Something else? Could you clarify please.



I can try  to be more clear... But I think that you provide me the good way
to do that in the Cayenne
spirit...
In a traditional architecture, services tier invoke dao tier to
retrieve/store data from db...
CRUD operations tainted with business experience are all present in one
tier: the dao one..
But all service operations won't invoke the same technical services in the
same manner ...
Batch operations invoked from daemons or reports won't use the same
underlying configuration for the same technical service .... A search page
against the customer database won't retrieve all customers while reports or
batches may want to retrieve the whole database isn't it ?
So I imagine to create (with a simple map) a repository of configurations (I
imagine that Metadata could have been these configurations but sounds false
after your first reply),  technical services being invoked with a simple
string parameter to point to one of the configuration...
We may think that business service don't need to know such low level of
details but it's the only way to avoid copy/paste and everybody knows danger
of code duplication.. I don't want to have 2 implementations of the same
search service even if there are 2 (or more) usage contexts..

I hope to be clear...
Once again I think that your answer is perfect.... It's just a refactoring
of the code I planned to put in place...


Cheers
jerome

Andrus
>
>


-- 
Jerome Moliere - Mentor/J
http://romjethoughts.blogspot.com/
auteur Eyrolles

Re: Querymetadata

Posted by Andrus Adamchik <an...@objectstyle.org>.
On Apr 16, 2007, at 3:28 PM, jerome moliere wrote:

> thanks for the reply andrus...
> so rather than imaginating factories with named  configuration  
> parameters
> (metadata) I'd  put in place  named  queries  carrying the   
> configuration ?
> Why not.....

Jerome,

As it happened in the past a few times, I suspect I don't fully  
understand what you are trying to do. Use a standard query? Build a  
custom query? Something else? Could you clarify please.

Andrus


Re: Querymetadata

Posted by jerome moliere <je...@gmail.com>.
2007/4/16, Andrus Adamchik <an...@objectstyle.org>:
>
> While tweaking QueryMetadata is often useful for custom queries, in
> this case it is not needed. Two most-often used concrete query
> classes, SelectQuery and SQLTemplate, define 'setFetchLimit' method
> and 'setPageSize' method.
>
> More on QueryMetadata... It is intended for Cayenne runtime to make
> sense of an unknown query, not for query configuration. So usually
> each concrete query provides setters for the subset of parameters
> that make sense for this query, and then the query itself generates
> appropriate metadata, hiding many details from the users.



thanks for the reply andrus...
so rather than imaginating factories with named  configuration parameters
(metadata) I'd  put in place  named  queries  carrying the  configuration ?
Why not.....

Thanks once again
Jerome

Andrus
>
> On Apr 16, 2007, at 2:50 PM, jerome moliere wrote:
>
> > Hi all,
> > playing around with cayenne, I'd like to set fetching limits and
> > page sizes
> > for my queries,
> > this seems to be done through QueryMetadata , but this interface
> > does not
> > provide any setter ..
> > So I'd like to know the proper way for forging its own metadata to
> > be passed
> > to the Query to be run...
> > I've seen a BaseMutableQueryMetadata class, but I guess I should
> > not be
> > obliged to make some uggly donwcasts, isn't it ?
> >
> > Is there a way to hook in the Cayenne queries generation mechanism to
> > configure the QueryMetaData to be used with my own settings ?
> > Did'nt see this, but I may be blind -)
> > Thanks for your help
> > cheers
> > jerome
> > --
> > Jerome Moliere - Mentor/J
> > http://romjethoughts.blogspot.com/
> > auteur Eyrolles
>
>


-- 
Jerome Moliere - Mentor/J
http://romjethoughts.blogspot.com/
auteur Eyrolles

Re: Querymetadata

Posted by Andrus Adamchik <an...@objectstyle.org>.
While tweaking QueryMetadata is often useful for custom queries, in  
this case it is not needed. Two most-often used concrete query  
classes, SelectQuery and SQLTemplate, define 'setFetchLimit' method  
and 'setPageSize' method.

More on QueryMetadata... It is intended for Cayenne runtime to make  
sense of an unknown query, not for query configuration. So usually  
each concrete query provides setters for the subset of parameters  
that make sense for this query, and then the query itself generates  
appropriate metadata, hiding many details from the users.

Andrus

On Apr 16, 2007, at 2:50 PM, jerome moliere wrote:

> Hi all,
> playing around with cayenne, I'd like to set fetching limits and  
> page sizes
> for my queries,
> this seems to be done through QueryMetadata , but this interface  
> does not
> provide any setter ..
> So I'd like to know the proper way for forging its own metadata to  
> be passed
> to the Query to be run...
> I've seen a BaseMutableQueryMetadata class, but I guess I should  
> not be
> obliged to make some uggly donwcasts, isn't it ?
>
> Is there a way to hook in the Cayenne queries generation mechanism to
> configure the QueryMetaData to be used with my own settings ?
> Did'nt see this, but I may be blind -)
> Thanks for your help
> cheers
> jerome
> -- 
> Jerome Moliere - Mentor/J
> http://romjethoughts.blogspot.com/
> auteur Eyrolles