Example usage for com.liferay.portal.kernel.dao.orm SQLQuery uniqueResult

List of usage examples for com.liferay.portal.kernel.dao.orm SQLQuery uniqueResult

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.dao.orm SQLQuery uniqueResult.

Prototype

public Object uniqueResult() throws ORMException;

Source Link

Usage

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.j  av  a2 s .  co  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/*  w ww  .  j  a va 2  s  .c  o  m*/
 * @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   w w w .j  av  a  2  s .  c o 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/* w ww.ja  v a  2  s  .  c om*/
 * @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//from www .  j a v a2  s .  c om
 * @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  www . jav a 2  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//www.  j a  v a  2 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.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/*from w  ww .j  a  v a2s .  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);
    }
}

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 sistemaTo = ?.
 *
 * @param sistemaTo the sistema to// ww  w.ja va2s.c  om
 * @return the number of matching relazioni sistemis that the user has permission to view
 * @throws SystemException if a system exception occurred
 */
public int filterCountBySistemaTo(String sistemaTo) throws SystemException {
    if (!InlineSQLHelperUtil.isEnabled()) {
        return countBySistemaTo(sistemaTo);
    }

    StringBundler query = new StringBundler(2);

    query.append(_FILTER_SQL_COUNT_RELAZIONISISTEMI_WHERE);

    if (sistemaTo == null) {
        query.append(_FINDER_COLUMN_SISTEMATO_SISTEMATO_1);
    } else {
        if (sistemaTo.equals(StringPool.BLANK)) {
            query.append(_FINDER_COLUMN_SISTEMATO_SISTEMATO_3);
        } else {
            query.append(_FINDER_COLUMN_SISTEMATO_SISTEMATO_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 (sistemaTo != null) {
            qPos.add(sistemaTo);
        }

        Long count = (Long) q.uniqueResult();

        return count.intValue();
    } catch (Exception e) {
        throw processException(e);
    } finally {
        closeSession(session);
    }
}

From source file:com.appuntivari.esempio.service.persistence.SistemiPersistenceImpl.java

License:Open Source License

/**
 * Returns the number of sistemis that the user has permission to view where sistema = ?.
 *
 * @param sistema the sistema/* w w w . j  a  v  a 2  s . c  o m*/
 * @return the number of matching sistemis that the user has permission to view
 * @throws SystemException if a system exception occurred
 */
public int filterCountBySistema(String sistema) throws SystemException {
    if (!InlineSQLHelperUtil.isEnabled()) {
        return countBySistema(sistema);
    }

    StringBundler query = new StringBundler(2);

    query.append(_FILTER_SQL_COUNT_SISTEMI_WHERE);

    if (sistema == null) {
        query.append(_FINDER_COLUMN_SISTEMA_SISTEMA_1);
    } else {
        if (sistema.equals(StringPool.BLANK)) {
            query.append(_FINDER_COLUMN_SISTEMA_SISTEMA_3);
        } else {
            query.append(_FINDER_COLUMN_SISTEMA_SISTEMA_2);
        }
    }

    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), Sistemi.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 (sistema != null) {
            qPos.add(sistema);
        }

        Long count = (Long) q.uniqueResult();

        return count.intValue();
    } catch (Exception e) {
        throw processException(e);
    } finally {
        closeSession(session);
    }
}