001package io.ebean.annotation; 002 003import java.lang.annotation.ElementType; 004import java.lang.annotation.Retention; 005import java.lang.annotation.RetentionPolicy; 006import java.lang.annotation.Target; 007 008/** 009 * Specify a property to be an aggregation formula. 010 * <p> 011 * The aggregation formula should be a sum, count, avg, min or max. 012 * By default aggregation properties are treated as transient and not 013 * included in a query. To populate the aggregation property it must be 014 * explicitly included in the select(). 015 * </p> 016 * 017 * <h3>Example:</h3> 018 * <pre>{@code 019 * 020 * @Aggregation("count(details)") 021 * Long totalCount; 022 * 023 * @Aggregation("sum(details.quantity*details.unitPrice)") 024 * Long totalAmount; 025 * 026 * }</pre> 027 * 028 * <h3>Example query</h3> 029 * <pre>{@code 030 * 031 * List<TEventOne> list = Ebean.find(TEventOne.class) 032 * .select("name, totalCount, totalUnits, totalAmount") 033 * .where() 034 * .startsWith("logs.description", "a") 035 * .having() 036 * .ge("count", 1) 037 * .orderBy().asc("name") 038 * .findList(); 039 * 040 * }</pre> 041 */ 042@Retention(RetentionPolicy.RUNTIME) 043@Target(ElementType.FIELD) 044public @interface Aggregation { 045 046 /** 047 * Aggregation formula using sum, count, avg, min, max. 048 */ 049 String value(); 050}