Search in sources :

Example 41 with StringBundler

use of com.liferay.petra.string.StringBundler in project liferay-blade-samples by liferay.

the class BazPersistenceImpl method countByUuid_C.

/**
 * Returns the number of bazs where uuid = ? and companyId = ?.
 *
 * @param uuid the uuid
 * @param companyId the company ID
 * @return the number of matching bazs
 */
@Override
public int countByUuid_C(String uuid, long companyId) {
    uuid = Objects.toString(uuid, "");
    FinderPath finderPath = _finderPathCountByUuid_C;
    Object[] finderArgs = new Object[] { uuid, companyId };
    Long count = (Long) finderCache.getResult(finderPath, finderArgs, this);
    if (count == null) {
        StringBundler query = new StringBundler(3);
        query.append(_SQL_COUNT_BAZ_WHERE);
        boolean bindUuid = false;
        if (uuid.isEmpty()) {
            query.append(_FINDER_COLUMN_UUID_C_UUID_3);
        } else {
            bindUuid = true;
            query.append(_FINDER_COLUMN_UUID_C_UUID_2);
        }
        query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
        String sql = query.toString();
        Session session = null;
        try {
            session = openSession();
            Query q = session.createQuery(sql);
            QueryPos qPos = QueryPos.getInstance(q);
            if (bindUuid) {
                qPos.add(uuid);
            }
            qPos.add(companyId);
            count = (Long) q.uniqueResult();
            finderCache.putResult(finderPath, finderArgs, count);
        } catch (Exception e) {
            finderCache.removeResult(finderPath, finderArgs);
            throw processException(e);
        } finally {
            closeSession(session);
        }
    }
    return count.intValue();
}
Also used : Query(com.liferay.portal.kernel.dao.orm.Query) FinderPath(com.liferay.portal.kernel.dao.orm.FinderPath) QueryPos(com.liferay.portal.kernel.dao.orm.QueryPos) StringBundler(com.liferay.petra.string.StringBundler) NoSuchBazException(com.liferay.blade.workflow.basic.exception.NoSuchBazException) Session(com.liferay.portal.kernel.dao.orm.Session)

Example 42 with StringBundler

use of com.liferay.petra.string.StringBundler in project liferay-blade-samples by liferay.

the class BazPersistenceImpl method findByUuid_C_First.

/**
 * Returns the first baz in the ordered set where uuid = ? and companyId = ?.
 *
 * @param uuid the uuid
 * @param companyId the company ID
 * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
 * @return the first matching baz
 * @throws NoSuchBazException if a matching baz could not be found
 */
@Override
public Baz findByUuid_C_First(String uuid, long companyId, OrderByComparator<Baz> orderByComparator) throws NoSuchBazException {
    Baz baz = fetchByUuid_C_First(uuid, companyId, orderByComparator);
    if (baz != null) {
        return baz;
    }
    StringBundler msg = new StringBundler(6);
    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
    msg.append("uuid=");
    msg.append(uuid);
    msg.append(", companyId=");
    msg.append(companyId);
    msg.append("}");
    throw new NoSuchBazException(msg.toString());
}
Also used : Baz(com.liferay.blade.workflow.basic.model.Baz) StringBundler(com.liferay.petra.string.StringBundler) NoSuchBazException(com.liferay.blade.workflow.basic.exception.NoSuchBazException)

Example 43 with StringBundler

use of com.liferay.petra.string.StringBundler in project liferay-blade-samples by liferay.

the class BazPersistenceImpl method findByUuid_Last.

/**
 * Returns the last baz in the ordered set where uuid = &#63;.
 *
 * @param uuid the uuid
 * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
 * @return the last matching baz
 * @throws NoSuchBazException if a matching baz could not be found
 */
@Override
public Baz findByUuid_Last(String uuid, OrderByComparator<Baz> orderByComparator) throws NoSuchBazException {
    Baz baz = fetchByUuid_Last(uuid, orderByComparator);
    if (baz != null) {
        return baz;
    }
    StringBundler msg = new StringBundler(4);
    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
    msg.append("uuid=");
    msg.append(uuid);
    msg.append("}");
    throw new NoSuchBazException(msg.toString());
}
Also used : Baz(com.liferay.blade.workflow.basic.model.Baz) StringBundler(com.liferay.petra.string.StringBundler) NoSuchBazException(com.liferay.blade.workflow.basic.exception.NoSuchBazException)

Example 44 with StringBundler

use of com.liferay.petra.string.StringBundler in project liferay-blade-samples by liferay.

the class BazPersistenceImpl method findByUUID_G.

/**
 * Returns the baz where uuid = &#63; and groupId = &#63; or throws a <code>NoSuchBazException</code> if it could not be found.
 *
 * @param uuid the uuid
 * @param groupId the group ID
 * @return the matching baz
 * @throws NoSuchBazException if a matching baz could not be found
 */
@Override
public Baz findByUUID_G(String uuid, long groupId) throws NoSuchBazException {
    Baz baz = fetchByUUID_G(uuid, groupId);
    if (baz == null) {
        StringBundler msg = new StringBundler(6);
        msg.append(_NO_SUCH_ENTITY_WITH_KEY);
        msg.append("uuid=");
        msg.append(uuid);
        msg.append(", groupId=");
        msg.append(groupId);
        msg.append("}");
        if (_log.isDebugEnabled()) {
            _log.debug(msg.toString());
        }
        throw new NoSuchBazException(msg.toString());
    }
    return baz;
}
Also used : Baz(com.liferay.blade.workflow.basic.model.Baz) StringBundler(com.liferay.petra.string.StringBundler) NoSuchBazException(com.liferay.blade.workflow.basic.exception.NoSuchBazException)

Example 45 with StringBundler

use of com.liferay.petra.string.StringBundler in project liferay-blade-samples by liferay.

the class BazPersistenceImpl method findByUuid_First.

/**
 * Returns the first baz in the ordered set where uuid = &#63;.
 *
 * @param uuid the uuid
 * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
 * @return the first matching baz
 * @throws NoSuchBazException if a matching baz could not be found
 */
@Override
public Baz findByUuid_First(String uuid, OrderByComparator<Baz> orderByComparator) throws NoSuchBazException {
    Baz baz = fetchByUuid_First(uuid, orderByComparator);
    if (baz != null) {
        return baz;
    }
    StringBundler msg = new StringBundler(4);
    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
    msg.append("uuid=");
    msg.append(uuid);
    msg.append("}");
    throw new NoSuchBazException(msg.toString());
}
Also used : Baz(com.liferay.blade.workflow.basic.model.Baz) StringBundler(com.liferay.petra.string.StringBundler) NoSuchBazException(com.liferay.blade.workflow.basic.exception.NoSuchBazException)

Aggregations

StringBundler (com.liferay.petra.string.StringBundler)90 Query (com.liferay.portal.kernel.dao.orm.Query)45 QueryPos (com.liferay.portal.kernel.dao.orm.QueryPos)38 Session (com.liferay.portal.kernel.dao.orm.Session)35 FinderPath (com.liferay.portal.kernel.dao.orm.FinderPath)31 Foo (com.liferay.blade.basic.model.Foo)17 Bar (com.liferay.blade.samples.servicebuilder.adq.model.Bar)17 NoSuchFooException (com.liferay.blade.basic.exception.NoSuchFooException)16 NoSuchBarException (com.liferay.blade.samples.servicebuilder.adq.exception.NoSuchBarException)16 HashMap (java.util.HashMap)14 LinkedHashMap (java.util.LinkedHashMap)14 Map (java.util.Map)14 Function (java.util.function.Function)14 Qux (com.liferay.blade.workflow.asset.model.Qux)13 Baz (com.liferay.blade.workflow.basic.model.Baz)13 NoSuchQuxException (com.liferay.blade.workflow.asset.exception.NoSuchQuxException)12 NoSuchBazException (com.liferay.blade.workflow.basic.exception.NoSuchBazException)12 List (java.util.List)4 Country (com.liferay.blade.samples.dspservicebuilder.model.Country)3 Country (com.liferay.blade.samples.jdbcservicebuilder.model.Country)3