Java Code Examples for org.springframework.dao.support.DataAccessUtils#intResult()
The following examples show how to use
org.springframework.dao.support.DataAccessUtils#intResult() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProductDao.java From DataHubSystem with GNU Affero General Public License v3.0 | 6 votes |
/** * Returns the number of Product records whose `processed` field is `true`. * @param filter an optional additionnal `where` clause (without the "where" token). * @param collection_uuid an optional parent collection ID. * @return a number of rows in table `PRODUCTS`. */ public int count (String filter, final String collection_uuid) { StringBuilder sb = new StringBuilder("select count(*) "); if (collection_uuid != null) { sb.append("from Collection c left outer join c.products p "); sb.append("where c.uuid='").append(collection_uuid).append("' and "); } else { sb.append("from Product p where "); } sb.append("p.processed=true"); if (filter != null && !filter.isEmpty()) { sb.append(" and ").append(filter); } return DataAccessUtils.intResult(find(sb.toString())); }
Example 2
Source File: HibernateDao.java From DataHubSystem with GNU Affero General Public License v3.0 | 6 votes |
@SuppressWarnings ("rawtypes") private int countOpenSessions () { return DataAccessUtils.intResult (getHibernateTemplate ().execute ( new HibernateCallback<List>() { @Override public List doInHibernate(Session session) throws HibernateException, SQLException { String sql = "SELECT count (*) FROM INFORMATION_SCHEMA.SYSTEM_SESSIONS"; SQLQuery query = session.createSQLQuery (sql); return query.list (); } })); }
Example 3
Source File: BaseDAO.java From bamboobsc with Apache License 2.0 | 5 votes |
@Override public int count(String hql, Object... args) throws Exception { Query query=this.getCurrentSession().createQuery(hql); for (int position=0; args!=null && position<args.length; position++) { this.setQueryParams(query, Integer.toString(position), args[position]); } return DataAccessUtils.intResult(query.list()); }
Example 4
Source File: GenericBaseCommonDao.java From jeecg with Apache License 2.0 | 5 votes |
/** * 查询指定实体的总记录数 * * @param clazz * @return */ public int getCount(Class<T> clazz) { int count = DataAccessUtils.intResult(getSession().createQuery( "select count(*) from " + clazz.getName()).list()); return count; }
Example 5
Source File: UserDao.java From DataHubSystem with GNU Affero General Public License v3.0 | 5 votes |
public int countNotDeletedByFilter (String filter) { return DataAccessUtils.intResult (find ( "select count(*) FROM " + entityClass.getName () + " u WHERE u.deleted is false AND (u.username LIKE '%" + filter + "%' OR lower(u.firstname) LIKE '%"+filter.toLowerCase()+ "%' OR lower(u.lastname) LIKE '%"+filter.toLowerCase()+ "%' OR lower(u.email) LIKE '%"+filter.toLowerCase()+ "%') and not u.username='" + cfgManager.getAdministratorConfiguration ().getName () + "'" + " and not u.username LIKE '"+getPublicData ().getUsername ()+"' ")); }
Example 6
Source File: UserDao.java From DataHubSystem with GNU Affero General Public License v3.0 | 5 votes |
public int countAll (String filter) { return DataAccessUtils.intResult (find ( "select count(*) FROM " + entityClass.getName () + " u WHERE u.username LIKE '%" + filter + "%'" + " and not u.username LIKE '" + getPublicData ().getUsername () + "' " )); }
Example 7
Source File: UserDao.java From DataHubSystem with GNU Affero General Public License v3.0 | 5 votes |
public int countNotDeleted (String filter) { return DataAccessUtils.intResult (find ( "select count(*) FROM " + entityClass.getName () + " u WHERE u.deleted is false AND u.username LIKE '%" + filter + "%' and " + "not u.username='" + cfgManager.getAdministratorConfiguration ().getName () + "'" + " and not u.username LIKE '"+getPublicData ().getUsername ()+"' ")); }
Example 8
Source File: GenericBaseCommonDao.java From jeewx with Apache License 2.0 | 5 votes |
/** * 查询指定实体的总记录数 * * @param clazz * @return */ public int getCount(Class<T> clazz) { int count = DataAccessUtils.intResult(getSession().createQuery( "select count(*) from " + clazz.getName()).list()); return count; }
Example 9
Source File: BaseDAO.java From bamboobsc with Apache License 2.0 | 5 votes |
public int countByEntityUK(Map<String, Object> ukMap) throws Exception { if (ukMap==null || ukMap.size()<1) { return 0; } Query query=this.getQueryByKeyMap("select count(*)", ukMap); return DataAccessUtils.intResult(query.list()); }
Example 10
Source File: BaseDAO.java From bamboobsc with Apache License 2.0 | 5 votes |
public int countByPK(Map<String, Object> pkMap) throws Exception { if (pkMap==null || pkMap.size()<1) { return 0; } Query query=this.getQueryByKeyMap("select count(*)", pkMap); return DataAccessUtils.intResult(query.list()); }
Example 11
Source File: BaseDAO.java From bamboobsc with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") public int countByPK(PK pk) throws Exception { return DataAccessUtils.intResult( this.getCurrentSession().createQuery( " select count(*) from "+this.getPersisentName() + " where " + BaseEntityUtil.getPKOneName((BaseEntity<PK>)entityClass.newInstance()) + "=?0 ") .setString("0", (String)pk).list()); }
Example 12
Source File: BaseDAO.java From bamboobsc with Apache License 2.0 | 5 votes |
public int countByEntityUK(Map<String, Object> ukMap) throws Exception { if (ukMap==null || ukMap.size()<1) { return 0; } Query query=this.getQueryByKeyMap("select count(*)", ukMap); return DataAccessUtils.intResult(query.list()); }
Example 13
Source File: BaseDAO.java From bamboobsc with Apache License 2.0 | 5 votes |
public int countByPK(Map<String, Object> pkMap) throws Exception { if (pkMap==null || pkMap.size()<1) { return 0; } Query query=this.getQueryByKeyMap("select count(*)", pkMap); return DataAccessUtils.intResult(query.list()); }
Example 14
Source File: BaseDAO.java From bamboobsc with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") public int countByPK(PK pk) throws Exception { return DataAccessUtils.intResult( this.getCurrentSession().createQuery( " select count(*) from "+this.getPersisentName() + " where " + BaseEntityUtil.getPKOneName((BaseEntity<PK>)entityClass.newInstance()) + "=?0 ") .setString("0", (String)pk).list()); }
Example 15
Source File: KpiDAOImpl.java From bamboobsc with Apache License 2.0 | 4 votes |
@Override public int countForMixData(Map<String, Object> paramMap) throws Exception { Query query = this.getCurrentSession().createQuery(this.getDynamicHql("findKpiMixData-count", paramMap)); this.setQueryMixDataParameter(query, paramMap); return DataAccessUtils.intResult( query.list() ); }
Example 16
Source File: GenericDaoImpl.java From oncokb with GNU Affero General Public License v3.0 | 4 votes |
@Override public int countAll() { return DataAccessUtils.intResult(find("select count(*) from " + getClassName())); }
Example 17
Source File: BaseDAO.java From bamboobsc with Apache License 2.0 | 4 votes |
@Override public int count(String hql) throws Exception { return DataAccessUtils.intResult(this.getCurrentSession().createQuery(hql).list()); //this.getHibernateTemplate().find(hql) }
Example 18
Source File: BaseDAO.java From bamboobsc with Apache License 2.0 | 4 votes |
@Override public int count(String hql) throws Exception { return DataAccessUtils.intResult(this.getCurrentSession().createQuery(hql).list()); }
Example 19
Source File: BaseDAO.java From QiQuYingServer with Apache License 2.0 | 2 votes |
/** * @Title: countBySql * @Description: 根据SQL统计查询结果数,多个参数调用 * @param @param hql * @param @param params * @param @return * @param @throws DataAccessException * @return int */ public <T> int countBySql(String sql, Object... params) throws DataAccessException { return DataAccessUtils.intResult(executeSQLQuery("select count(*) " + sql.substring(sql.toLowerCase().indexOf("from")), params)); }
Example 20
Source File: BaseDAO.java From QiQuYingServer with Apache License 2.0 | 2 votes |
/** * @Title: countByHql * @Description: 根据HQL统计查询结果数,多个参数调用 * @param @param hql * @param @param params * @param @return * @param @throws DataAccessException * @return int */ public <T> int countByHql(String hql, Object... params) throws DataAccessException { return DataAccessUtils.intResult(getHibernateTemplate().find(hql, params)); }