cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joe Baldwin <jfbald...@earthlink.net>
Subject Re: count(*) with parameter
Date Mon, 19 Apr 2010 17:15:15 GMT
Arnaud,

For example: I think you can add stored procedures via the CayenneModeler (CM).  I have not
used this feature yet, and so I do not know if this is even an optimum solution.  (Maybe the
Cayenne team knows the answer to this.)

You could try this out and then do some performance testing to decide what is best. (I would
be interested in the result.)

My design was to create a custom Persistence Factory class and add convenience methods as
I need them.  I also located a lot of CayenneDataObject-related methods in the CayenneDataObject's
subclass. As I learned more about Cayenne features, I was able to easily update this kind
of design for performance enhancements and bug fixes.  (This is just my opinion.)

Your decision might come down to performance or simply whether your design concepts are better
handled fromm the DBMS or OO perspective.

Joe

On Apr 19, 2010, at 12:28 PM, Arnaud Garcia wrote:

> Hi and thanks,
> 
> Well both, modeler and code (just for my cayenne understanding...)
> And in the modeler ?
> 
> Arnaud
> 
> 2010/4/18 Joe Baldwin <jfbaldwin@earthlink.net>
> 
>> Arnaud,
>> 
>> If I understand you, I think you want to do this in the code and not the
>> modeler?
>> 
>> Here is a simple code fragment for a like-ignore-case qualifier:
>> 
>>       String substring = "Martin";
>>       ObjectContext oc = BaseContext.getThreadObjectContext();
>>       Expression exp =
>> ExpressionFactory.likeIgnoreCaseExp(Product.NAME_PROPERTY, ("%" + substring
>> + "%"));
>>       SelectQuery query = new SelectQuery(Product.class, exp);
>>       List list = oc.performQuery(query);
>>       System.out.println("\ncount: " + list.size());
>> 
>> This is pretty efficient and to my knowledge does not trigger any
>> DataObject faults.  There are a few other ways to do this depending on your
>> design.  The ExpresionFactory has a lot of powerful methods to help you out.
>> 
>> Joe
>> 
>> 
>> 
>> 
>> On Apr 18, 2010, at 12:15 PM, Arnaud Garcia wrote:
>> 
>>> Hello,
>>> 
>>> I am not sure how to create a select count(*) in the modeler when I need
>> to
>>> pass a parameter ?
>>> I downloaded the petstore example, and it seems that I have to create a
>> "Raw
>>> SQL" Query, and directly write my select count(*)...
>>> 
>>> =>but how to I had my parameter in my SQL ?
>>> 
>>> ... then I suppose I can do ctxt.performQuery("myCount",params,true) ?
>>> 
>>> thanks for help for this beginner question...
>>> 
>>> Arnaud
>> 
>> 


Mime
View raw message