Hi Mark,

For doing a count (and a few others), you can try using this:

https://github.com/mrg/cbe/blob/master/FetchingObjects/Aggregates/src/main/java/cbe/fetching/utilities/AggregateUtils.java

Example usage code is here:

https://github.com/mrg/cbe/blob/master/FetchingObjects/Aggregates/src/main/java/cbe/fetching/Aggregates.java

For your insert/update rows, I think you'll have to write that yourself.
If your "data" dictionary/map object uses keys that match your entity's
attribute names, You can probably loop over they keys and write the values
using CayenneDataObject's writeProperty() method (CDO is a superclass of
your actual entities).

mrg



On Sun, Jun 12, 2016 at 4:53 PM, Mark Wardle <[email protected]> wrote:

> Dear all,
>
> I'm implementing a new project using Cayenne based on some code currently
> running in a live application built using WO/EOF/Wonder (see
> https://github.com/wardle/rsterminology)
>
> Migrating to Cayenne has been very straightforward so far.
>
> Within Project Wonder, there are a large number of utility methods to make
> it easy to deal with qualifiers (expressions) and perform database agnostic
> batch operations without using SQL.
>
> ERXEOControlUtilities.objectCountWithQualifier(ec, entityName, qual);
>
> which takes a qualifier (essentially a Cayenne expression) and an entity
> and performs a count.
>
> ERXEOAccessUtilities.insertRow(ec, entityName, data);
>
> which takes a context, entity name and dictionary (a map) and inserts the
> values without having to deal with entities (a bit like a DataRow I think
> in Cayenne?).
>
> For example, we have
> ERXEOAccessUtilities.updateRowsDescribedByQualifier(ec, entityName, qual,
> data);
> which takes a context, entity name, qualifier and a dictionary of data and
> updates rows based on that data.
>
> Are there equivalent utility methods within Cayenne please? I have found
> SQLTemplate but, it looks as if I'd have to hand-tune the expression to
> update and get embroiled in creating to logic to understand the DbEntity
> and its properties in order to map a map. It feels as if I'm probably
> fighting the framework and so normally that suggests I'm approaching it
> wrong!
>
> Advice for a WO-er appreciated.
>
> Best wishes,
>
> Mark
>

Reply via email to