[語法] 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