You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by "Nikita Timofeev (JIRA)" <ji...@apache.org> on 2017/01/25 14:22:26 UTC
[jira] [Closed] (CAY-2209) Shortcuts for aggregate functions
[ https://issues.apache.org/jira/browse/CAY-2209?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Nikita Timofeev closed CAY-2209.
--------------------------------
Resolution: Fixed
https://github.com/apache/cayenne/commit/3f8a8f196ed2aca1a07470f33ae51d66251bda38
> Shortcuts for aggregate functions
> ---------------------------------
>
> Key: CAY-2209
> URL: https://issues.apache.org/jira/browse/CAY-2209
> Project: Cayenne
> Issue Type: Sub-task
> Components: Core Library
> Reporter: Nikita Timofeev
> Assignee: Nikita Timofeev
>
> # new methods in ObjectSelect and ColumnSelect
> #* min
> #* max
> #* avg
> #* sum
> #* count
> # new methods in Property class
> #* min
> #* max
> #* avg
> #* sum
> #* count
> #* plus constant Property.COUNT
> # ColumnSelect can be created only via ObjectSelect (methods *columnQuery(...)*)
> {code}
> // Select COUNT(*) examples:
> long count = ObjectSelect
> .columnQuery(Artist.class, Property.COUNT) // constant property
> .selectOne(context);
> long count2 = ObjectSelect
> .query(Artist.class)
> .count()
> .selectOne(context);
> long count3 = ObjectSelect
> .query(Artist.class)
> .selectCount(context); // new select*() method
> // Select COUNT(attributes) examples:
> long count2 = ObjectSelect
> .columnQuery(Artist.class, Artist.DATE_OF_BIRTH.count()) // new methods in Property class
> .selectOne(context);
> long count3 = ObjectSelect
> .query(Artist.class)
> .count(Artist.DATE_OF_BIRTH)
> .selectOne(context);
> // All aggregates:
> Property<BigDecimal> estimatedPrice = Artist.PAINTING_ARRAY.dot(Painting.ESTIMATED_PRICE);
> Object[] minMaxAvgSumCount = ObjectSelect.query(Artist.class)
> .where(estimatedPrice.gte(min))
> .min(estimatedPrice)
> .max(estimatedPrice)
> .avg(estimatedPrice)
> .sum(estimatedPrice)
> .count()
> .selectOne(context);
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)