Hi Anthony,
I think the feature you are after in Cayenne is Named Queries. In the
CayenneModeler click on the "Create Query" icon, then in dialog
"Select New Query Type" select the "Raw Query" option and then
"Create" button.
This will take you to a screen where you can define the query name and
specify other options. In the "SQL Scripts" tab you enter in your SQL
query and can specify different SQL scripts for the different
databases, e.g. Oracle vs SQL Server.
In your script you can specify parameters and use Velocity for
dynamically creating conditional statements. Very powerful.
In your Java you create a named and pass in any parameters.
protected List performNamedQuery(String queryName, Map parameters) {
return getDataContext().performQuery(queryName, parameters, true);
}
By default this will return you a list of RowMap objects, with each
map representing a row, with the column names as the key.
regards Malcolm Edgar
On Wed, Apr 8, 2009 at 3:46 PM, Andrus Adamchik <andru..bjectstyle.org> wrote:
> Cayenne 3.0 includes support for EJBQLQuery which seem like you what you
> need here:
>
> http://cayenne.apache.org/doc/ejbqlquery.html
>
> We are following the JPA syntax per JSR-220
> (http://jcp.org/aboutJava/communityprocess/final/jsr220/index.html). At does
> support aggregates, separate columns, subqueries, etc. Anything not
> supported by the EJBQLQuery will indeed require a SQLTemplate, which is not
> as scary as it sounds.
>
> Hope this helps.
>
> Andrus
>
> On Apr 8, 2009, at 8:26 AM, Weddle, Anthony wrote:
>
>> We're looking at moving from Hibernate to Cayenne but I'm having trouble
>> finding out how to perform queries that return arbitrary data, maybe
>> they are sometimes called report queries. Something like Hibernate's HQL
>> queries that can return arbitrary data (including aggregate functions or
>> simply a bunch of columns from different tables that may have formal or
>> informal relationships).
>>
>>
>>
>> I can't seem to find any examples of this. All of the query classes seem
>> to require a specific class (or some specific entity) and the
>> SQLTemplateQuery doesn't take Expression qualifiers or interpret POJO
>> property paths.
>>
>>
>>
>> I assume that there is a not too complicated way to perform arbitrary
>> queries, without having to go to raw SQL. Is that true?
>>
>>
>>
>> Thanks,
>>
>> Tony
>>
>>
>>
>>
>>
>> NOTICE - This message and any attached files may contain information that
>> is confidential, legally privileged or proprietary. It is intended only for
>> use by the intended recipient. If you are not the intended recipient or the
>> person responsible for delivering the message to the intended recipient, be
>> advised that you have received this message in error. Any dissemination,
>> copying, use or re-transmission of this message or attachment, or the
>> disclosure of any information therein, is strictly forbidden. BlueScope
>> Steel Limited does not represent or guarantee that this message or
>> attachment is free of errors, virus or interference.
>>
>> If you have received this message in error please notify the sender
>> immediately and delete the message. Any views expressed in this email are
>> not necessarily the views of BlueScope Steel Limited.
>
>
This archive was generated by hypermail 2.0.0 : Wed Apr 08 2009 - 05:13:33 EDT