cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Harunobu Oyama ...@telensa.com>
Subject Re: Aggregate function
Date Fri, 15 Jul 2016 15:17:52 GMT
Hi Michael,

Thank you for your message. I will give it a try.

As for "reading_id", yes it is the primary key and actually generated by
using bigserial.
While I was populating 3 billions of those, I wrote a throw-away code to
assign the
value from the Java code without spending time on sequence query. It did
made the
data population about 20% faster. The query was meant to be used to find
out the
initial value, but I even cheated to hard code the value this time.

nobu


On 15 July 2016 at 15:49, Michael Gentry <blacknext@gmail.com> wrote:

> Hi Nobu,
>
> I have an AggregateUtils that I use:
>
>
> https://github.com/mrg/cbe/tree/master/FetchingObjects/Aggregates/src/main/java/cbe/fetching/utilities
>
> Here is an example of code using AggregateUtils:
>
>
> https://github.com/mrg/cbe/blob/master/FetchingObjects/Aggregates/src/main/java/cbe/fetching/Aggregates.java
>
> To use it for your example would be something like this:
>
> SelectQuery query = new SelectQuery(Reading.class);
> BigDecimal max = AggregateUtils.max(dataContext, query,
> READING.READING_ID_PROPERTY);
>
> On a side note, I'm guessing "reading_id" is your primary key?  If so, why
> are you trying to get the maximum value for it?  Is the primary key/id not
> being generated by the database?
>
> mrg
>
>
> On Fri, Jul 15, 2016 at 5:56 AM, Harunobu Oyama <ho@telensa.com> wrote:
>
> > Hi,
> >
> > What is the Cayenne way to execute aggregate functions?
> >
> > For example, SELECT MAX("reading_id") FROM "reading" ?
> >
> > I tried passing SQLTemplate containing the SQL written above
> > to performGenericQuery method, with no luck. Are we supposed to use JDBC?
> > If so, what is the best way to get the JDBC Connection?
> >
> > Any hint would be appreciated.
> >
> > thank you,
> > nobu
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message