[语法] Criteria JPA 语法

楼主: airhong (艾尔洪斯)   2020-11-03 16:25:29
您好
我想写SELECT SUM(cevecoin) FROM coin where clid="ABC";
但一直都没办法成功 可以帮我看看吗? 谢谢
code如下
@Override
public Integer SumCoin(String Clid) {
CriteriaBuilder builder =getSession().getCriteriaBuilder();
CriteriaQuery<CoinBean> criteria =builder.createQuery(CoinBean.class);
Root<CoinBean> root = criteria.from(CoinBean.class);
builder.sum(root.get("Clid"));
return
getSession().createQuery(criteria).getSingleResult().getCevecoin();
}

Links booklink

Contact Us: admin [ a t ] ucptt.com