JpaBaseDao.java 文件源码

java
阅读 36 收藏 0 点赞 0 评论 0

项目:VaadinUtils 作者:
/**
 * @return the number of entities in the table.
 */
public long getCount()
{
    String entityName = entityClass.getSimpleName();
    Table annotation = entityClass.getAnnotation(Table.class);
    String tableName;
    if (annotation != null)
    {
        tableName = annotation.name();
    }
    else
    {
        tableName = entityName;
    }

    String qry = "select count(" + entityName + ") from " + tableName + " " + entityName;
    Query query = getEntityManager().createQuery(qry);
    Number countResult = (Number) query.getSingleResult();
    return countResult.longValue();

}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号