use of com.liferay.petra.string.StringBundler in project liferay-blade-samples by liferay.
the class QuxPersistenceImpl method countByUUID_G.
/**
* Returns the number of quxs where uuid = ? and groupId = ?.
*
* @param uuid the uuid
* @param groupId the group ID
* @return the number of matching quxs
*/
@Override
public int countByUUID_G(String uuid, long groupId) {
uuid = Objects.toString(uuid, "");
FinderPath finderPath = _finderPathCountByUUID_G;
Object[] finderArgs = new Object[] { uuid, groupId };
Long count = (Long) finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler query = new StringBundler(3);
query.append(_SQL_COUNT_QUX_WHERE);
boolean bindUuid = false;
if (uuid.isEmpty()) {
query.append(_FINDER_COLUMN_UUID_G_UUID_3);
} else {
bindUuid = true;
query.append(_FINDER_COLUMN_UUID_G_UUID_2);
}
query.append(_FINDER_COLUMN_UUID_G_GROUPID_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(groupId);
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();
}
use of com.liferay.petra.string.StringBundler in project liferay-blade-samples by liferay.
the class QuxPersistenceImpl method findByUUID_G.
/**
* Returns the qux where uuid = ? and groupId = ? or throws a <code>NoSuchQuxException</code> if it could not be found.
*
* @param uuid the uuid
* @param groupId the group ID
* @return the matching qux
* @throws NoSuchQuxException if a matching qux could not be found
*/
@Override
public Qux findByUUID_G(String uuid, long groupId) throws NoSuchQuxException {
Qux qux = fetchByUUID_G(uuid, groupId);
if (qux == 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 NoSuchQuxException(msg.toString());
}
return qux;
}
use of com.liferay.petra.string.StringBundler in project liferay-blade-samples by liferay.
the class QuxPersistenceImpl method countByUuid_C.
/**
* Returns the number of quxs where uuid = ? and companyId = ?.
*
* @param uuid the uuid
* @param companyId the company ID
* @return the number of matching quxs
*/
@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_QUX_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();
}
use of com.liferay.petra.string.StringBundler in project liferay-blade-samples by liferay.
the class BazPersistenceImpl method fetchByUUID_G.
/**
* Returns the baz where uuid = ? and groupId = ? or returns <code>null</code> if it could not be found, optionally using the finder cache.
*
* @param uuid the uuid
* @param groupId the group ID
* @param retrieveFromCache whether to retrieve from the finder cache
* @return the matching baz, or <code>null</code> if a matching baz could not be found
*/
@Override
public Baz fetchByUUID_G(String uuid, long groupId, boolean retrieveFromCache) {
uuid = Objects.toString(uuid, "");
Object[] finderArgs = new Object[] { uuid, groupId };
Object result = null;
if (retrieveFromCache) {
result = finderCache.getResult(_finderPathFetchByUUID_G, finderArgs, this);
}
if (result instanceof Baz) {
Baz baz = (Baz) result;
if (!Objects.equals(uuid, baz.getUuid()) || (groupId != baz.getGroupId())) {
result = null;
}
}
if (result == null) {
StringBundler query = new StringBundler(4);
query.append(_SQL_SELECT_BAZ_WHERE);
boolean bindUuid = false;
if (uuid.isEmpty()) {
query.append(_FINDER_COLUMN_UUID_G_UUID_3);
} else {
bindUuid = true;
query.append(_FINDER_COLUMN_UUID_G_UUID_2);
}
query.append(_FINDER_COLUMN_UUID_G_GROUPID_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(groupId);
List<Baz> list = q.list();
if (list.isEmpty()) {
finderCache.putResult(_finderPathFetchByUUID_G, finderArgs, list);
} else {
Baz baz = list.get(0);
result = baz;
cacheResult(baz);
}
} catch (Exception e) {
finderCache.removeResult(_finderPathFetchByUUID_G, finderArgs);
throw processException(e);
} finally {
closeSession(session);
}
}
if (result instanceof List<?>) {
return null;
} else {
return (Baz) result;
}
}
use of com.liferay.petra.string.StringBundler in project liferay-blade-samples by liferay.
the class BazPersistenceImpl method findAll.
/**
* Returns an ordered range of all the bazs.
*
* <p>
* Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not <code>QueryUtil#ALL_POS</code>), then the query will include the default ORDER BY logic from <code>BazModelImpl</code>. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
* </p>
*
* @param start the lower bound of the range of bazs
* @param end the upper bound of the range of bazs (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
* @param retrieveFromCache whether to retrieve from the finder cache
* @return the ordered range of bazs
*/
@Override
public List<Baz> findAll(int start, int end, OrderByComparator<Baz> orderByComparator, boolean retrieveFromCache) {
boolean pagination = true;
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) {
pagination = false;
finderPath = _finderPathWithoutPaginationFindAll;
finderArgs = FINDER_ARGS_EMPTY;
} else {
finderPath = _finderPathWithPaginationFindAll;
finderArgs = new Object[] { start, end, orderByComparator };
}
List<Baz> list = null;
if (retrieveFromCache) {
list = (List<Baz>) finderCache.getResult(finderPath, finderArgs, this);
}
if (list == null) {
StringBundler query = null;
String sql = null;
if (orderByComparator != null) {
query = new StringBundler(2 + (orderByComparator.getOrderByFields().length * 2));
query.append(_SQL_SELECT_BAZ);
appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
sql = query.toString();
} else {
sql = _SQL_SELECT_BAZ;
if (pagination) {
sql = sql.concat(BazModelImpl.ORDER_BY_JPQL);
}
}
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
if (!pagination) {
list = (List<Baz>) QueryUtil.list(q, getDialect(), start, end, false);
Collections.sort(list);
list = Collections.unmodifiableList(list);
} else {
list = (List<Baz>) QueryUtil.list(q, getDialect(), start, end);
}
cacheResult(list);
finderCache.putResult(finderPath, finderArgs, list);
} catch (Exception e) {
finderCache.removeResult(finderPath, finderArgs);
throw processException(e);
} finally {
closeSession(session);
}
}
return list;
}
Aggregations