use of com.liferay.petra.string.StringBundler in project liferay-blade-samples by liferay.
the class FooPersistenceImpl method findByUuid_First.
/**
* Returns the first foo in the ordered set where uuid = ?.
*
* @param uuid the uuid
* @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
* @return the first matching foo
* @throws NoSuchFooException if a matching foo could not be found
*/
@Override
public Foo findByUuid_First(String uuid, OrderByComparator<Foo> orderByComparator) throws NoSuchFooException {
Foo foo = fetchByUuid_First(uuid, orderByComparator);
if (foo != null) {
return foo;
}
StringBundler msg = new StringBundler(4);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("uuid=");
msg.append(uuid);
msg.append("}");
throw new NoSuchFooException(msg.toString());
}
use of com.liferay.petra.string.StringBundler in project liferay-blade-samples by liferay.
the class FooPersistenceImpl method findByUuid_C_Last.
/**
* Returns the last foo 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 last matching foo
* @throws NoSuchFooException if a matching foo could not be found
*/
@Override
public Foo findByUuid_C_Last(String uuid, long companyId, OrderByComparator<Foo> orderByComparator) throws NoSuchFooException {
Foo foo = fetchByUuid_C_Last(uuid, companyId, orderByComparator);
if (foo != null) {
return foo;
}
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 NoSuchFooException(msg.toString());
}
use of com.liferay.petra.string.StringBundler in project liferay-blade-samples by liferay.
the class FooPersistenceImpl method countByUuid.
/**
* Returns the number of foos where uuid = ?.
*
* @param uuid the uuid
* @return the number of matching foos
*/
@Override
public int countByUuid(String uuid) {
uuid = Objects.toString(uuid, "");
FinderPath finderPath = _finderPathCountByUuid;
Object[] finderArgs = new Object[] { uuid };
Long count = (Long) finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler query = new StringBundler(2);
query.append(_SQL_COUNT_FOO_WHERE);
boolean bindUuid = false;
if (uuid.isEmpty()) {
query.append(_FINDER_COLUMN_UUID_UUID_3);
} else {
bindUuid = true;
query.append(_FINDER_COLUMN_UUID_UUID_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);
}
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 FooPersistenceImpl method countByUuid_C.
/**
* Returns the number of foos where uuid = ? and companyId = ?.
*
* @param uuid the uuid
* @param companyId the company ID
* @return the number of matching foos
*/
@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_FOO_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 FooPersistenceImpl method findByUuid_C.
/**
* Returns an ordered range of all the foos where uuid = ? and companyId = ?.
*
* <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, then the query will include the default ORDER BY logic from <code>FooModelImpl</code>.
* </p>
*
* @param uuid the uuid
* @param companyId the company ID
* @param start the lower bound of the range of foos
* @param end the upper bound of the range of foos (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
* @param useFinderCache whether to use the finder cache
* @return the ordered range of matching foos
*/
@Override
public List<Foo> findByUuid_C(String uuid, long companyId, int start, int end, OrderByComparator<Foo> orderByComparator, boolean useFinderCache) {
uuid = Objects.toString(uuid, "");
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) {
if (useFinderCache) {
finderPath = _finderPathWithoutPaginationFindByUuid_C;
finderArgs = new Object[] { uuid, companyId };
}
} else if (useFinderCache) {
finderPath = _finderPathWithPaginationFindByUuid_C;
finderArgs = new Object[] { uuid, companyId, start, end, orderByComparator };
}
List<Foo> list = null;
if (useFinderCache) {
list = (List<Foo>) finderCache.getResult(finderPath, finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (Foo foo : list) {
if (!uuid.equals(foo.getUuid()) || (companyId != foo.getCompanyId())) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler query = null;
if (orderByComparator != null) {
query = new StringBundler(4 + (orderByComparator.getOrderByFields().length * 2));
} else {
query = new StringBundler(4);
}
query.append(_SQL_SELECT_FOO_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);
if (orderByComparator != null) {
appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
} else {
query.append(FooModelImpl.ORDER_BY_JPQL);
}
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);
list = (List<Foo>) QueryUtil.list(q, getDialect(), start, end);
cacheResult(list);
if (useFinderCache) {
finderCache.putResult(finderPath, finderArgs, list);
}
} catch (Exception e) {
if (useFinderCache) {
finderCache.removeResult(finderPath, finderArgs);
}
throw processException(e);
} finally {
closeSession(session);
}
}
return list;
}
Aggregations