mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#1331 - ENH: Support Aggregation formula with findSingleAttribute() ... max, min, avg, count and count(distinct ..)
This commit is contained in:
@@ -13,17 +13,27 @@ import java.util.List;
|
||||
@Entity
|
||||
public class TEventOne {
|
||||
|
||||
public enum Status {
|
||||
AA,
|
||||
BB
|
||||
}
|
||||
|
||||
@Id
|
||||
Long id;
|
||||
|
||||
String name;
|
||||
|
||||
Status status;
|
||||
|
||||
@Version
|
||||
Long version;
|
||||
|
||||
@OneToOne
|
||||
TEvent event;
|
||||
|
||||
@Aggregation("max(version)")
|
||||
Long maxVersion;
|
||||
|
||||
@Aggregation("count(logs.id)")
|
||||
Long count;
|
||||
|
||||
@@ -36,8 +46,14 @@ public class TEventOne {
|
||||
@OneToMany(mappedBy = "event", cascade = CascadeType.ALL)
|
||||
List<TEventMany> logs;
|
||||
|
||||
public TEventOne(String name) {
|
||||
public TEventOne(String name, Status status) {
|
||||
this.name = name;
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "id:" + id + " name:" + name + " status:" + status + " mv:" + maxVersion + " ct:" + count;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
@@ -60,10 +76,18 @@ public class TEventOne {
|
||||
return totalAmount;
|
||||
}
|
||||
|
||||
public Long getMaxVersion() {
|
||||
return maxVersion;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public Status getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user