use of com.liferay.petra.string.StringBundler in project liferay-blade-samples by liferay.
the class QuxPersistenceImpl method findAll.
/**
* Returns an ordered range of all the quxs.
*
* <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>QuxModelImpl</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 quxs
* @param end the upper bound of the range of quxs (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 quxs
*/
@Override
public List<Qux> findAll(int start, int end, OrderByComparator<Qux> 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<Qux> list = null;
if (retrieveFromCache) {
list = (List<Qux>) 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_QUX);
appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
sql = query.toString();
} else {
sql = _SQL_SELECT_QUX;
if (pagination) {
sql = sql.concat(QuxModelImpl.ORDER_BY_JPQL);
}
}
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
if (!pagination) {
list = (List<Qux>) QueryUtil.list(q, getDialect(), start, end, false);
Collections.sort(list);
list = Collections.unmodifiableList(list);
} else {
list = (List<Qux>) 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;
}
use of com.liferay.petra.string.StringBundler in project liferay-blade-samples by liferay.
the class QuxPersistenceImpl method fetchByUUID_G.
/**
* Returns the qux 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 qux, or <code>null</code> if a matching qux could not be found
*/
@Override
public Qux 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 Qux) {
Qux qux = (Qux) result;
if (!Objects.equals(uuid, qux.getUuid()) || (groupId != qux.getGroupId())) {
result = null;
}
}
if (result == null) {
StringBundler query = new StringBundler(4);
query.append(_SQL_SELECT_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);
List<Qux> list = q.list();
if (list.isEmpty()) {
finderCache.putResult(_finderPathFetchByUUID_G, finderArgs, list);
} else {
Qux qux = list.get(0);
result = qux;
cacheResult(qux);
}
} catch (Exception e) {
finderCache.removeResult(_finderPathFetchByUUID_G, finderArgs);
throw processException(e);
} finally {
closeSession(session);
}
}
if (result instanceof List<?>) {
return null;
} else {
return (Qux) result;
}
}
use of com.liferay.petra.string.StringBundler in project liferay-blade-samples by liferay.
the class QuxPersistenceImpl method findByUuid.
/**
* Returns an ordered range of all the quxs where uuid = ?.
*
* <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>QuxModelImpl</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 uuid the uuid
* @param start the lower bound of the range of quxs
* @param end the upper bound of the range of quxs (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 matching quxs
*/
@Override
public List<Qux> findByUuid(String uuid, int start, int end, OrderByComparator<Qux> orderByComparator, boolean retrieveFromCache) {
uuid = Objects.toString(uuid, "");
boolean pagination = true;
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) {
pagination = false;
finderPath = _finderPathWithoutPaginationFindByUuid;
finderArgs = new Object[] { uuid };
} else {
finderPath = _finderPathWithPaginationFindByUuid;
finderArgs = new Object[] { uuid, start, end, orderByComparator };
}
List<Qux> list = null;
if (retrieveFromCache) {
list = (List<Qux>) finderCache.getResult(finderPath, finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (Qux qux : list) {
if (!uuid.equals(qux.getUuid())) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler query = null;
if (orderByComparator != null) {
query = new StringBundler(3 + (orderByComparator.getOrderByFields().length * 2));
} else {
query = new StringBundler(3);
}
query.append(_SQL_SELECT_QUX_WHERE);
boolean bindUuid = false;
if (uuid.isEmpty()) {
query.append(_FINDER_COLUMN_UUID_UUID_3);
} else {
bindUuid = true;
query.append(_FINDER_COLUMN_UUID_UUID_2);
}
if (orderByComparator != null) {
appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
} else if (pagination) {
query.append(QuxModelImpl.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);
}
if (!pagination) {
list = (List<Qux>) QueryUtil.list(q, getDialect(), start, end, false);
Collections.sort(list);
list = Collections.unmodifiableList(list);
} else {
list = (List<Qux>) 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;
}
use of com.liferay.petra.string.StringBundler in project liferay-blade-samples by liferay.
the class BazPersistenceImpl method findByUuid.
/**
* Returns an ordered range of all the bazs where uuid = ?.
*
* <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 uuid the uuid
* @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 matching bazs
*/
@Override
public List<Baz> findByUuid(String uuid, int start, int end, OrderByComparator<Baz> orderByComparator, boolean retrieveFromCache) {
uuid = Objects.toString(uuid, "");
boolean pagination = true;
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) {
pagination = false;
finderPath = _finderPathWithoutPaginationFindByUuid;
finderArgs = new Object[] { uuid };
} else {
finderPath = _finderPathWithPaginationFindByUuid;
finderArgs = new Object[] { uuid, start, end, orderByComparator };
}
List<Baz> list = null;
if (retrieveFromCache) {
list = (List<Baz>) finderCache.getResult(finderPath, finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (Baz baz : list) {
if (!uuid.equals(baz.getUuid())) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler query = null;
if (orderByComparator != null) {
query = new StringBundler(3 + (orderByComparator.getOrderByFields().length * 2));
} else {
query = new StringBundler(3);
}
query.append(_SQL_SELECT_BAZ_WHERE);
boolean bindUuid = false;
if (uuid.isEmpty()) {
query.append(_FINDER_COLUMN_UUID_UUID_3);
} else {
bindUuid = true;
query.append(_FINDER_COLUMN_UUID_UUID_2);
}
if (orderByComparator != null) {
appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
} else if (pagination) {
query.append(BazModelImpl.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);
}
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;
}
use of com.liferay.petra.string.StringBundler in project liferay-blade-samples by liferay.
the class BazPersistenceImpl method findByUuid_C_Last.
/**
* Returns the last 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 last matching baz
* @throws NoSuchBazException if a matching baz could not be found
*/
@Override
public Baz findByUuid_C_Last(String uuid, long companyId, OrderByComparator<Baz> orderByComparator) throws NoSuchBazException {
Baz baz = fetchByUuid_C_Last(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());
}
Aggregations