List of usage examples for com.liferay.portal.kernel.dao.orm SQLQuery addScalar
public SQLQuery addScalar(String columnAlias, Type type);
From source file:at.meduni.liferay.portlet.bbmrieric.service.persistence.D2BiobankPersistenceImpl.java
License:Open Source License
/** * Returns the number of d2 biobanks that the user has permission to view where groupId = ?. * * @param groupId the group ID//from w w w . ja va 2 s .c o m * @return the number of matching d2 biobanks that the user has permission to view * @throws SystemException if a system exception occurred */ @Override public int filterCountByGroupId(long groupId) throws SystemException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return countByGroupId(groupId); } StringBundler query = new StringBundler(2); query.append(_FILTER_SQL_COUNT_D2BIOBANK_WHERE); query.append(_FINDER_COLUMN_GROUPID_GROUPID_2); String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), D2Biobank.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); Session session = null; try { session = openSession(); SQLQuery q = session.createSQLQuery(sql); q.addScalar(COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); Long count = (Long) q.uniqueResult(); return count.intValue(); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } }
From source file:at.meduni.liferay.portlet.bbmrieric.service.persistence.D2BiobankPersistenceImpl.java
License:Open Source License
/** * Returns the number of d2 biobanks that the user has permission to view where groupId = ? and biobankName = ?. * * @param groupId the group ID/*from w ww . j a v a 2s. c om*/ * @param biobankName the biobank name * @return the number of matching d2 biobanks that the user has permission to view * @throws SystemException if a system exception occurred */ @Override public int filterCountByBiobankName(long groupId, String biobankName) throws SystemException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return countByBiobankName(groupId, biobankName); } StringBundler query = new StringBundler(3); query.append(_FILTER_SQL_COUNT_D2BIOBANK_WHERE); query.append(_FINDER_COLUMN_BIOBANKNAME_GROUPID_2); boolean bindBiobankName = false; if (biobankName == null) { query.append(_FINDER_COLUMN_BIOBANKNAME_BIOBANKNAME_1); } else if (biobankName.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_BIOBANKNAME_BIOBANKNAME_3); } else { bindBiobankName = true; query.append(_FINDER_COLUMN_BIOBANKNAME_BIOBANKNAME_2); } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), D2Biobank.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); Session session = null; try { session = openSession(); SQLQuery q = session.createSQLQuery(sql); q.addScalar(COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); if (bindBiobankName) { qPos.add(biobankName); } Long count = (Long) q.uniqueResult(); return count.intValue(); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } }
From source file:at.meduni.liferay.portlet.bbmrieric.service.persistence.D2BiobankPersistenceImpl.java
License:Open Source License
/** * Returns the number of d2 biobanks that the user has permission to view where groupId = ? and status = ?. * * @param groupId the group ID/*from www .j a v a2s . co m*/ * @param status the status * @return the number of matching d2 biobanks that the user has permission to view * @throws SystemException if a system exception occurred */ @Override public int filterCountByG_S(long groupId, int status) throws SystemException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return countByG_S(groupId, status); } StringBundler query = new StringBundler(3); query.append(_FILTER_SQL_COUNT_D2BIOBANK_WHERE); query.append(_FINDER_COLUMN_G_S_GROUPID_2); query.append(_FINDER_COLUMN_G_S_STATUS_2); String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), D2Biobank.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); Session session = null; try { session = openSession(); SQLQuery q = session.createSQLQuery(sql); q.addScalar(COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(status); Long count = (Long) q.uniqueResult(); return count.intValue(); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } }
From source file:at.meduni.liferay.portlet.bbmrieric.service.persistence.D2BiobankPersistenceImpl.java
License:Open Source License
/** * Returns the number of d2 biobanks that the user has permission to view where groupId = ? and biobankId = ?. * * @param groupId the group ID//from ww w .java 2s. co m * @param biobankId the biobank ID * @return the number of matching d2 biobanks that the user has permission to view * @throws SystemException if a system exception occurred */ @Override public int filterCountByBiobank(long groupId, long biobankId) throws SystemException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return countByBiobank(groupId, biobankId); } StringBundler query = new StringBundler(3); query.append(_FILTER_SQL_COUNT_D2BIOBANK_WHERE); query.append(_FINDER_COLUMN_BIOBANK_GROUPID_2); query.append(_FINDER_COLUMN_BIOBANK_BIOBANKID_2); String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), D2Biobank.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); Session session = null; try { session = openSession(); SQLQuery q = session.createSQLQuery(sql); q.addScalar(COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(biobankId); Long count = (Long) q.uniqueResult(); return count.intValue(); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } }
From source file:at.meduni.liferay.portlet.bbmrieric.service.persistence.D2BiobankPersistenceImpl.java
License:Open Source License
/** * Returns the number of d2 biobanks that the user has permission to view where groupId = ? and updateuuid ≠ ?. * * @param groupId the group ID// ww w . j a v a 2 s . com * @param updateuuid the updateuuid * @return the number of matching d2 biobanks that the user has permission to view * @throws SystemException if a system exception occurred */ @Override public int filterCountByNotUUID(long groupId, String updateuuid) throws SystemException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return countByNotUUID(groupId, updateuuid); } StringBundler query = new StringBundler(3); query.append(_FILTER_SQL_COUNT_D2BIOBANK_WHERE); query.append(_FINDER_COLUMN_NOTUUID_GROUPID_2); boolean bindUpdateuuid = false; if (updateuuid == null) { query.append(_FINDER_COLUMN_NOTUUID_UPDATEUUID_1); } else if (updateuuid.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_NOTUUID_UPDATEUUID_3); } else { bindUpdateuuid = true; query.append(_FINDER_COLUMN_NOTUUID_UPDATEUUID_2); } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), D2Biobank.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); Session session = null; try { session = openSession(); SQLQuery q = session.createSQLQuery(sql); q.addScalar(COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); if (bindUpdateuuid) { qPos.add(updateuuid); } Long count = (Long) q.uniqueResult(); return count.intValue(); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } }
From source file:br.com.prodevelopment.associado.service.persistence.AssociadoPersistenceImpl.java
License:Open Source License
/** * Returns the number of associados that the user has permission to view where companyId = ? and groupId = ?. * * @param companyId the company ID//from ww w. j a v a2 s. c o m * @param groupId the group ID * @return the number of matching associados that the user has permission to view * @throws SystemException if a system exception occurred */ @Override public int filterCountByC_G(long companyId, long groupId) throws SystemException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return countByC_G(companyId, groupId); } StringBundler query = new StringBundler(3); query.append(_FILTER_SQL_COUNT_ASSOCIADO_WHERE); query.append(_FINDER_COLUMN_C_G_COMPANYID_2); query.append(_FINDER_COLUMN_C_G_GROUPID_2); String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), Associado.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); Session session = null; try { session = openSession(); SQLQuery q = session.createSQLQuery(sql); q.addScalar(COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG); QueryPos qPos = QueryPos.getInstance(q); qPos.add(companyId); qPos.add(groupId); Long count = (Long) q.uniqueResult(); return count.intValue(); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } }
From source file:br.com.prodevelopment.associado.service.persistence.AssociadoPersistenceImpl.java
License:Open Source License
/** * Returns the number of associados that the user has permission to view where companyId = ? and groupId = ? and nome LIKE ?. * * @param companyId the company ID/*from ww w . ja va2 s .c o m*/ * @param groupId the group ID * @param nome the nome * @return the number of matching associados that the user has permission to view * @throws SystemException if a system exception occurred */ @Override public int filterCountByC_G_NOME(long companyId, long groupId, String nome) throws SystemException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return countByC_G_NOME(companyId, groupId, nome); } StringBundler query = new StringBundler(4); query.append(_FILTER_SQL_COUNT_ASSOCIADO_WHERE); query.append(_FINDER_COLUMN_C_G_NOME_COMPANYID_2); query.append(_FINDER_COLUMN_C_G_NOME_GROUPID_2); boolean bindNome = false; if (nome == null) { query.append(_FINDER_COLUMN_C_G_NOME_NOME_1); } else if (nome.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_C_G_NOME_NOME_3); } else { bindNome = true; query.append(_FINDER_COLUMN_C_G_NOME_NOME_2); } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), Associado.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); Session session = null; try { session = openSession(); SQLQuery q = session.createSQLQuery(sql); q.addScalar(COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG); QueryPos qPos = QueryPos.getInstance(q); qPos.add(companyId); qPos.add(groupId); if (bindNome) { qPos.add(nome); } Long count = (Long) q.uniqueResult(); return count.intValue(); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } }
From source file:com.amf.registration.service.persistence.AMFUserFinderImpl.java
License:Open Source License
public int countByZip(String zip) throws SystemException { Session session = null;//w w w. ja va 2s .c o m try { session = openSession(); String sql = CustomSQLUtil.get(COUNT_BY_ZIP); SQLQuery q = session.createSQLQuery(sql); q.addScalar(COUNT_COLUMN_NAME, Type.LONG); QueryPos qPos = QueryPos.getInstance(q); qPos.add(zip); Iterator<Long> itr = q.iterate(); if (itr.hasNext()) { Long count = itr.next(); if (count != null) { return count.intValue(); } } return 0; } catch (Exception e) { throw new SystemException(e); } finally { closeSession(session); } }
From source file:com.amf.registration.service.persistence.AMFUserFinderImpl.java
License:Open Source License
public List<User> findByZip(String zip, int start, int end) throws SystemException { Session session = null;//from w ww . j av a2 s. c om List<User> users = new ArrayList<User>(); try { session = openSession(); String sql = CustomSQLUtil.get(FIND_BY_ZIP); SQLQuery q = session.createSQLQuery(sql); q.addScalar("userId", Type.LONG); QueryPos qPos = QueryPos.getInstance(q); qPos.add(zip); List<Long> userIds = (List<Long>) QueryUtil.list(q, getDialect(), start, end); for (long userId : userIds) { User user = UserLocalServiceUtil.fetchUser(userId); users.add(user); } return users; } catch (Exception e) { throw new SystemException(e); } finally { closeSession(session); } }
From source file:com.appuntivari.esempio.service.persistence.RelazioniSistemiPersistenceImpl.java
License:Open Source License
/** * Returns the number of relazioni sistemis that the user has permission to view where sistemaFrom = ?. * * @param sistemaFrom the sistema from/* ww w .j a v a 2s .co m*/ * @return the number of matching relazioni sistemis that the user has permission to view * @throws SystemException if a system exception occurred */ public int filterCountBySistemaFrom(String sistemaFrom) throws SystemException { if (!InlineSQLHelperUtil.isEnabled()) { return countBySistemaFrom(sistemaFrom); } StringBundler query = new StringBundler(2); query.append(_FILTER_SQL_COUNT_RELAZIONISISTEMI_WHERE); if (sistemaFrom == null) { query.append(_FINDER_COLUMN_SISTEMAFROM_SISTEMAFROM_1); } else { if (sistemaFrom.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_SISTEMAFROM_SISTEMAFROM_3); } else { query.append(_FINDER_COLUMN_SISTEMAFROM_SISTEMAFROM_2); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), RelazioniSistemi.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN); Session session = null; try { session = openSession(); SQLQuery q = session.createSQLQuery(sql); q.addScalar(COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG); QueryPos qPos = QueryPos.getInstance(q); if (sistemaFrom != null) { qPos.add(sistemaFrom); } Long count = (Long) q.uniqueResult(); return count.intValue(); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } }