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

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

Introduction

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

Prototype

public Object uniqueResult() throws ORMException;

Source Link

Usage

From source file:at.bibbox.reactjsservice.service.persistence.ToolInformationPersistenceImpl.java

License:Open Source License

/**
 * Returns the number of tool informations where category = ?.
 *
 * @param category the category/*from   w w  w  .  j av a  2 s . co m*/
 * @return the number of matching tool informations
 * @throws SystemException if a system exception occurred
 */
@Override
public int countByCategory(String category) throws SystemException {
    FinderPath finderPath = FINDER_PATH_COUNT_BY_CATEGORY;

    Object[] finderArgs = new Object[] { category };

    Long count = (Long) FinderCacheUtil.getResult(finderPath, finderArgs, this);

    if (count == null) {
        StringBundler query = new StringBundler(2);

        query.append(_SQL_COUNT_TOOLINFORMATION_WHERE);

        boolean bindCategory = false;

        if (category == null) {
            query.append(_FINDER_COLUMN_CATEGORY_CATEGORY_1);
        } else if (category.equals(StringPool.BLANK)) {
            query.append(_FINDER_COLUMN_CATEGORY_CATEGORY_3);
        } else {
            bindCategory = true;

            query.append(_FINDER_COLUMN_CATEGORY_CATEGORY_2);
        }

        String sql = query.toString();

        Session session = null;

        try {
            session = openSession();

            Query q = session.createQuery(sql);

            QueryPos qPos = QueryPos.getInstance(q);

            if (bindCategory) {
                qPos.add(category);
            }

            count = (Long) q.uniqueResult();

            FinderCacheUtil.putResult(finderPath, finderArgs, count);
        } catch (Exception e) {
            FinderCacheUtil.removeResult(finderPath, finderArgs);

            throw processException(e);
        } finally {
            closeSession(session);
        }
    }

    return count.intValue();
}

From source file:at.bibbox.reactjsservice.service.persistence.ToolInformationPersistenceImpl.java

License:Open Source License

/**
 * Returns the number of tool informations.
 *
 * @return the number of tool informations
 * @throws SystemException if a system exception occurred
 *//*from  w  w w .j ava 2  s. c  o  m*/
@Override
public int countAll() throws SystemException {
    Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY, this);

    if (count == null) {
        Session session = null;

        try {
            session = openSession();

            Query q = session.createQuery(_SQL_COUNT_TOOLINFORMATION);

            count = (Long) q.uniqueResult();

            FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY, count);
        } catch (Exception e) {
            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY);

            throw processException(e);
        } finally {
            closeSession(session);
        }
    }

    return count.intValue();
}

From source file:at.graz.hmmc.liferay.portlet.puch.service.persistence.ConfigurationPersistenceImpl.java

License:Open Source License

/**
 * Returns the number of configurations where scope = ? and optionkey = ?.
 *
 * @param scope the scope//from  w w w  .j a va  2  s. c o  m
 * @param optionkey the optionkey
 * @return the number of matching configurations
 * @throws SystemException if a system exception occurred
 */
@Override
public int countByoptionFinder(String scope, String optionkey) throws SystemException {
    FinderPath finderPath = FINDER_PATH_COUNT_BY_OPTIONFINDER;

    Object[] finderArgs = new Object[] { scope, optionkey };

    Long count = (Long) FinderCacheUtil.getResult(finderPath, finderArgs, this);

    if (count == null) {
        StringBundler query = new StringBundler(3);

        query.append(_SQL_COUNT_CONFIGURATION_WHERE);

        boolean bindScope = false;

        if (scope == null) {
            query.append(_FINDER_COLUMN_OPTIONFINDER_SCOPE_1);
        } else if (scope.equals(StringPool.BLANK)) {
            query.append(_FINDER_COLUMN_OPTIONFINDER_SCOPE_3);
        } else {
            bindScope = true;

            query.append(_FINDER_COLUMN_OPTIONFINDER_SCOPE_2);
        }

        boolean bindOptionkey = false;

        if (optionkey == null) {
            query.append(_FINDER_COLUMN_OPTIONFINDER_OPTIONKEY_1);
        } else if (optionkey.equals(StringPool.BLANK)) {
            query.append(_FINDER_COLUMN_OPTIONFINDER_OPTIONKEY_3);
        } else {
            bindOptionkey = true;

            query.append(_FINDER_COLUMN_OPTIONFINDER_OPTIONKEY_2);
        }

        String sql = query.toString();

        Session session = null;

        try {
            session = openSession();

            Query q = session.createQuery(sql);

            QueryPos qPos = QueryPos.getInstance(q);

            if (bindScope) {
                qPos.add(scope);
            }

            if (bindOptionkey) {
                qPos.add(optionkey);
            }

            count = (Long) q.uniqueResult();

            FinderCacheUtil.putResult(finderPath, finderArgs, count);
        } catch (Exception e) {
            FinderCacheUtil.removeResult(finderPath, finderArgs);

            throw processException(e);
        } finally {
            closeSession(session);
        }
    }

    return count.intValue();
}

From source file:at.graz.hmmc.liferay.portlet.puch.service.persistence.ConfigurationPersistenceImpl.java

License:Open Source License

/**
 * Returns the number of configurations where scope = ? and optionvalue = ?.
 *
 * @param scope the scope//  ww w  .j  av a2 s.c o  m
 * @param optionvalue the optionvalue
 * @return the number of matching configurations
 * @throws SystemException if a system exception occurred
 */
@Override
public int countByoptionsFinderValue(String scope, String optionvalue) throws SystemException {
    FinderPath finderPath = FINDER_PATH_COUNT_BY_OPTIONSFINDERVALUE;

    Object[] finderArgs = new Object[] { scope, optionvalue };

    Long count = (Long) FinderCacheUtil.getResult(finderPath, finderArgs, this);

    if (count == null) {
        StringBundler query = new StringBundler(3);

        query.append(_SQL_COUNT_CONFIGURATION_WHERE);

        boolean bindScope = false;

        if (scope == null) {
            query.append(_FINDER_COLUMN_OPTIONSFINDERVALUE_SCOPE_1);
        } else if (scope.equals(StringPool.BLANK)) {
            query.append(_FINDER_COLUMN_OPTIONSFINDERVALUE_SCOPE_3);
        } else {
            bindScope = true;

            query.append(_FINDER_COLUMN_OPTIONSFINDERVALUE_SCOPE_2);
        }

        boolean bindOptionvalue = false;

        if (optionvalue == null) {
            query.append(_FINDER_COLUMN_OPTIONSFINDERVALUE_OPTIONVALUE_1);
        } else if (optionvalue.equals(StringPool.BLANK)) {
            query.append(_FINDER_COLUMN_OPTIONSFINDERVALUE_OPTIONVALUE_3);
        } else {
            bindOptionvalue = true;

            query.append(_FINDER_COLUMN_OPTIONSFINDERVALUE_OPTIONVALUE_2);
        }

        String sql = query.toString();

        Session session = null;

        try {
            session = openSession();

            Query q = session.createQuery(sql);

            QueryPos qPos = QueryPos.getInstance(q);

            if (bindScope) {
                qPos.add(scope);
            }

            if (bindOptionvalue) {
                qPos.add(optionvalue);
            }

            count = (Long) q.uniqueResult();

            FinderCacheUtil.putResult(finderPath, finderArgs, count);
        } catch (Exception e) {
            FinderCacheUtil.removeResult(finderPath, finderArgs);

            throw processException(e);
        } finally {
            closeSession(session);
        }
    }

    return count.intValue();
}

From source file:at.graz.hmmc.liferay.portlet.puch.service.persistence.ConfigurationPersistenceImpl.java

License:Open Source License

/**
 * Returns the number of configurations where scope = ? and optionkey = ?.
 *
 * @param scope the scope//from   w w  w .  j  a  v a 2s.co  m
 * @param optionkey the optionkey
 * @return the number of matching configurations
 * @throws SystemException if a system exception occurred
 */
@Override
public int countByoptionsFinderKey(String scope, String optionkey) throws SystemException {
    FinderPath finderPath = FINDER_PATH_COUNT_BY_OPTIONSFINDERKEY;

    Object[] finderArgs = new Object[] { scope, optionkey };

    Long count = (Long) FinderCacheUtil.getResult(finderPath, finderArgs, this);

    if (count == null) {
        StringBundler query = new StringBundler(3);

        query.append(_SQL_COUNT_CONFIGURATION_WHERE);

        boolean bindScope = false;

        if (scope == null) {
            query.append(_FINDER_COLUMN_OPTIONSFINDERKEY_SCOPE_1);
        } else if (scope.equals(StringPool.BLANK)) {
            query.append(_FINDER_COLUMN_OPTIONSFINDERKEY_SCOPE_3);
        } else {
            bindScope = true;

            query.append(_FINDER_COLUMN_OPTIONSFINDERKEY_SCOPE_2);
        }

        boolean bindOptionkey = false;

        if (optionkey == null) {
            query.append(_FINDER_COLUMN_OPTIONSFINDERKEY_OPTIONKEY_1);
        } else if (optionkey.equals(StringPool.BLANK)) {
            query.append(_FINDER_COLUMN_OPTIONSFINDERKEY_OPTIONKEY_3);
        } else {
            bindOptionkey = true;

            query.append(_FINDER_COLUMN_OPTIONSFINDERKEY_OPTIONKEY_2);
        }

        String sql = query.toString();

        Session session = null;

        try {
            session = openSession();

            Query q = session.createQuery(sql);

            QueryPos qPos = QueryPos.getInstance(q);

            if (bindScope) {
                qPos.add(scope);
            }

            if (bindOptionkey) {
                qPos.add(optionkey);
            }

            count = (Long) q.uniqueResult();

            FinderCacheUtil.putResult(finderPath, finderArgs, count);
        } catch (Exception e) {
            FinderCacheUtil.removeResult(finderPath, finderArgs);

            throw processException(e);
        } finally {
            closeSession(session);
        }
    }

    return count.intValue();
}

From source file:at.graz.hmmc.liferay.portlet.puch.service.persistence.ConfigurationPersistenceImpl.java

License:Open Source License

/**
 * Returns the number of configurations where scope = ?.
 *
 * @param scope the scope//from w  w w .  j  a  v a  2  s.  co  m
 * @return the number of matching configurations
 * @throws SystemException if a system exception occurred
 */
@Override
public int countByoptionsFinder(String scope) throws SystemException {
    FinderPath finderPath = FINDER_PATH_COUNT_BY_OPTIONSFINDER;

    Object[] finderArgs = new Object[] { scope };

    Long count = (Long) FinderCacheUtil.getResult(finderPath, finderArgs, this);

    if (count == null) {
        StringBundler query = new StringBundler(2);

        query.append(_SQL_COUNT_CONFIGURATION_WHERE);

        boolean bindScope = false;

        if (scope == null) {
            query.append(_FINDER_COLUMN_OPTIONSFINDER_SCOPE_1);
        } else if (scope.equals(StringPool.BLANK)) {
            query.append(_FINDER_COLUMN_OPTIONSFINDER_SCOPE_3);
        } else {
            bindScope = true;

            query.append(_FINDER_COLUMN_OPTIONSFINDER_SCOPE_2);
        }

        String sql = query.toString();

        Session session = null;

        try {
            session = openSession();

            Query q = session.createQuery(sql);

            QueryPos qPos = QueryPos.getInstance(q);

            if (bindScope) {
                qPos.add(scope);
            }

            count = (Long) q.uniqueResult();

            FinderCacheUtil.putResult(finderPath, finderArgs, count);
        } catch (Exception e) {
            FinderCacheUtil.removeResult(finderPath, finderArgs);

            throw processException(e);
        } finally {
            closeSession(session);
        }
    }

    return count.intValue();
}

From source file:at.graz.hmmc.liferay.portlet.puch.service.persistence.ConfigurationPersistenceImpl.java

License:Open Source License

/**
 * Returns the number of configurations where optionkey = ?.
 *
 * @param optionkey the optionkey//from   www . j ava2  s  .  c  om
 * @return the number of matching configurations
 * @throws SystemException if a system exception occurred
 */
@Override
public int countByOptionsFinderForKey(String optionkey) throws SystemException {
    FinderPath finderPath = FINDER_PATH_COUNT_BY_OPTIONSFINDERFORKEY;

    Object[] finderArgs = new Object[] { optionkey };

    Long count = (Long) FinderCacheUtil.getResult(finderPath, finderArgs, this);

    if (count == null) {
        StringBundler query = new StringBundler(2);

        query.append(_SQL_COUNT_CONFIGURATION_WHERE);

        boolean bindOptionkey = false;

        if (optionkey == null) {
            query.append(_FINDER_COLUMN_OPTIONSFINDERFORKEY_OPTIONKEY_1);
        } else if (optionkey.equals(StringPool.BLANK)) {
            query.append(_FINDER_COLUMN_OPTIONSFINDERFORKEY_OPTIONKEY_3);
        } else {
            bindOptionkey = true;

            query.append(_FINDER_COLUMN_OPTIONSFINDERFORKEY_OPTIONKEY_2);
        }

        String sql = query.toString();

        Session session = null;

        try {
            session = openSession();

            Query q = session.createQuery(sql);

            QueryPos qPos = QueryPos.getInstance(q);

            if (bindOptionkey) {
                qPos.add(optionkey);
            }

            count = (Long) q.uniqueResult();

            FinderCacheUtil.putResult(finderPath, finderArgs, count);
        } catch (Exception e) {
            FinderCacheUtil.removeResult(finderPath, finderArgs);

            throw processException(e);
        } finally {
            closeSession(session);
        }
    }

    return count.intValue();
}

From source file:at.graz.hmmc.liferay.portlet.puch.service.persistence.ConfigurationPersistenceImpl.java

License:Open Source License

/**
 * Returns the number of configurations.
 *
 * @return the number of configurations/*  w  w w. jav a 2 s. c  om*/
 * @throws SystemException if a system exception occurred
 */
@Override
public int countAll() throws SystemException {
    Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY, this);

    if (count == null) {
        Session session = null;

        try {
            session = openSession();

            Query q = session.createQuery(_SQL_COUNT_CONFIGURATION);

            count = (Long) q.uniqueResult();

            FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY, count);
        } catch (Exception e) {
            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY);

            throw processException(e);
        } finally {
            closeSession(session);
        }
    }

    return count.intValue();
}

From source file:at.graz.hmmc.liferay.portlet.puch.service.persistence.FahrzeugPersistenceImpl.java

License:Open Source License

/**
 * Returns the number of fahrzeugs where typ = ?.
 *
 * @param typ the typ/*from w ww .  j  av a2  s.  com*/
 * @return the number of matching fahrzeugs
 * @throws SystemException if a system exception occurred
 */
@Override
public int countByTyp(String typ) throws SystemException {
    FinderPath finderPath = FINDER_PATH_COUNT_BY_TYP;

    Object[] finderArgs = new Object[] { typ };

    Long count = (Long) FinderCacheUtil.getResult(finderPath, finderArgs, this);

    if (count == null) {
        StringBundler query = new StringBundler(2);

        query.append(_SQL_COUNT_FAHRZEUG_WHERE);

        boolean bindTyp = false;

        if (typ == null) {
            query.append(_FINDER_COLUMN_TYP_TYP_1);
        } else if (typ.equals(StringPool.BLANK)) {
            query.append(_FINDER_COLUMN_TYP_TYP_3);
        } else {
            bindTyp = true;

            query.append(_FINDER_COLUMN_TYP_TYP_2);
        }

        String sql = query.toString();

        Session session = null;

        try {
            session = openSession();

            Query q = session.createQuery(sql);

            QueryPos qPos = QueryPos.getInstance(q);

            if (bindTyp) {
                qPos.add(typ);
            }

            count = (Long) q.uniqueResult();

            FinderCacheUtil.putResult(finderPath, finderArgs, count);
        } catch (Exception e) {
            FinderCacheUtil.removeResult(finderPath, finderArgs);

            throw processException(e);
        } finally {
            closeSession(session);
        }
    }

    return count.intValue();
}

From source file:at.graz.hmmc.liferay.portlet.puch.service.persistence.FahrzeugPersistenceImpl.java

License:Open Source License

/**
 * Returns the number of fahrzeugs./*from   ww  w. ja v  a  2s  .c  o m*/
 *
 * @return the number of fahrzeugs
 * @throws SystemException if a system exception occurred
 */
@Override
public int countAll() throws SystemException {
    Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY, this);

    if (count == null) {
        Session session = null;

        try {
            session = openSession();

            Query q = session.createQuery(_SQL_COUNT_FAHRZEUG);

            count = (Long) q.uniqueResult();

            FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY, count);
        } catch (Exception e) {
            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY);

            throw processException(e);
        } finally {
            closeSession(session);
        }
    }

    return count.intValue();
}