我有一个包含以下列的表:
@Column(name="CTDESTATUS")
private String status;
@Column (name= "CTDEMESSAGE")
private String message;
@Temporal(TemporalType.TIMESTAMP)
@Column (name = "CTDTDATE")
private Date date;
@Column (name = "CTCDSERVICEID")
private String serviceId;
我需要构建一个查询,该查询返回n
添加到数据库的最后一行,按 分组serviceId
,其中每一行是包含以下内容之一的旧行status
:
START
或RUNNING
或PAUSED
或END_ERROR
或END_SUCCESS
并按降序对结果进行排序date
。我不熟悉 Eclipselink API,我想要这样的东西:
ExpressionBuilder builder = new ExpressionBuilder();
Expression exStatus1 = builder.get("status").equal("START");
Expression exStatus2 = builder.get("status").equal("RUNNING");
Expression exStatus3 = builder.get("status").equal("PAUSED");
Expression exStatus4 = builder.get("status").equal("END_ERROR");
Expression exStatus5 = builder.get("status").equal("END_SUCCESS");
Expression exStatus = (exStatus1).or(exStatus2).or(exStatus3).or(exStatus4).or(exStatus5);
Expression exGroup = builder.get("serviceId").distinct();
Expression exOrder = builder.get("date").descending();
ReadAllQuery query = new ReadAllQuery();
query.setReferenceClass(Notification.class);
query.setSelectionCriteria(exStatus);
query.addDescendingOrdering("date");
query.setMaxRows(n);
有人可以帮助我吗?