use of com.liferay.blade.samples.servicebuilder.adq.model.Bar in project liferay-blade-samples by liferay.
the class BarPersistenceImpl method findAll.
/**
* Returns an ordered range of all the bars.
*
* <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>BarModelImpl</code>.
* </p>
*
* @param start the lower bound of the range of bars
* @param end the upper bound of the range of bars (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 bars
*/
@Override
public List<Bar> findAll(int start, int end, OrderByComparator<Bar> orderByComparator, boolean useFinderCache) {
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) {
if (useFinderCache) {
finderPath = _finderPathWithoutPaginationFindAll;
finderArgs = FINDER_ARGS_EMPTY;
}
} else if (useFinderCache) {
finderPath = _finderPathWithPaginationFindAll;
finderArgs = new Object[] { start, end, orderByComparator };
}
List<Bar> list = null;
if (useFinderCache) {
list = (List<Bar>) 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_BAR);
appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
sql = query.toString();
} else {
sql = _SQL_SELECT_BAR;
sql = sql.concat(BarModelImpl.ORDER_BY_JPQL);
}
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
list = (List<Bar>) 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;
}
use of com.liferay.blade.samples.servicebuilder.adq.model.Bar in project liferay-blade-samples by liferay.
the class BarPersistenceImpl method findByUuid_PrevAndNext.
/**
* Returns the bars before and after the current bar in the ordered set where uuid = ?.
*
* @param barId the primary key of the current bar
* @param uuid the uuid
* @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
* @return the previous, current, and next bar
* @throws NoSuchBarException if a bar with the primary key could not be found
*/
@Override
public Bar[] findByUuid_PrevAndNext(long barId, String uuid, OrderByComparator<Bar> orderByComparator) throws NoSuchBarException {
uuid = Objects.toString(uuid, "");
Bar bar = findByPrimaryKey(barId);
Session session = null;
try {
session = openSession();
Bar[] array = new BarImpl[3];
array[0] = getByUuid_PrevAndNext(session, bar, uuid, orderByComparator, true);
array[1] = bar;
array[2] = getByUuid_PrevAndNext(session, bar, uuid, orderByComparator, false);
return array;
} catch (Exception e) {
throw processException(e);
} finally {
closeSession(session);
}
}
use of com.liferay.blade.samples.servicebuilder.adq.model.Bar in project liferay-blade-samples by liferay.
the class BarPersistenceImpl method findByUuid_C_PrevAndNext.
/**
* Returns the bars before and after the current bar in the ordered set where uuid = ? and companyId = ?.
*
* @param barId the primary key of the current bar
* @param uuid the uuid
* @param companyId the company ID
* @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
* @return the previous, current, and next bar
* @throws NoSuchBarException if a bar with the primary key could not be found
*/
@Override
public Bar[] findByUuid_C_PrevAndNext(long barId, String uuid, long companyId, OrderByComparator<Bar> orderByComparator) throws NoSuchBarException {
uuid = Objects.toString(uuid, "");
Bar bar = findByPrimaryKey(barId);
Session session = null;
try {
session = openSession();
Bar[] array = new BarImpl[3];
array[0] = getByUuid_C_PrevAndNext(session, bar, uuid, companyId, orderByComparator, true);
array[1] = bar;
array[2] = getByUuid_C_PrevAndNext(session, bar, uuid, companyId, orderByComparator, false);
return array;
} catch (Exception e) {
throw processException(e);
} finally {
closeSession(session);
}
}
use of com.liferay.blade.samples.servicebuilder.adq.model.Bar in project liferay-blade-samples by liferay.
the class BarPersistenceImpl method findByField2_PrevAndNext.
/**
* Returns the bars before and after the current bar in the ordered set where field2 = ?.
*
* @param barId the primary key of the current bar
* @param field2 the field2
* @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
* @return the previous, current, and next bar
* @throws NoSuchBarException if a bar with the primary key could not be found
*/
@Override
public Bar[] findByField2_PrevAndNext(long barId, boolean field2, OrderByComparator<Bar> orderByComparator) throws NoSuchBarException {
Bar bar = findByPrimaryKey(barId);
Session session = null;
try {
session = openSession();
Bar[] array = new BarImpl[3];
array[0] = getByField2_PrevAndNext(session, bar, field2, orderByComparator, true);
array[1] = bar;
array[2] = getByField2_PrevAndNext(session, bar, field2, orderByComparator, false);
return array;
} catch (Exception e) {
throw processException(e);
} finally {
closeSession(session);
}
}
use of com.liferay.blade.samples.servicebuilder.adq.model.Bar in project liferay-blade-samples by liferay.
the class BarPersistenceTest method testFetchByPrimaryKeysWithOnePrimaryKey.
@Test
public void testFetchByPrimaryKeysWithOnePrimaryKey() throws Exception {
Bar newBar = addBar();
Set<Serializable> primaryKeys = new HashSet<Serializable>();
primaryKeys.add(newBar.getPrimaryKey());
Map<Serializable, Bar> bars = _persistence.fetchByPrimaryKeys(primaryKeys);
Assert.assertEquals(1, bars.size());
Assert.assertEquals(newBar, bars.get(newBar.getPrimaryKey()));
}
Aggregations