use of com.liferay.blade.samples.dspservicebuilder.model.Country in project liferay-blade-samples by liferay.
the class CountryPersistenceImpl method findAll.
/**
* Returns an ordered range of all the countries.
*
* <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>CountryModelImpl</code>.
* </p>
*
* @param start the lower bound of the range of countries
* @param end the upper bound of the range of countries (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 countries
*/
@Override
public List<Country> findAll(int start, int end, OrderByComparator<Country> 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<Country> list = null;
if (useFinderCache) {
list = (List<Country>) finderCache.getResult(finderPath, finderArgs, this);
}
if (list == null) {
StringBundler sb = null;
String sql = null;
if (orderByComparator != null) {
sb = new StringBundler(2 + (orderByComparator.getOrderByFields().length * 2));
sb.append(_SQL_SELECT_COUNTRY);
appendOrderByComparator(sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
sql = sb.toString();
} else {
sql = _SQL_SELECT_COUNTRY;
sql = sql.concat(CountryModelImpl.ORDER_BY_JPQL);
}
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
list = (List<Country>) QueryUtil.list(query, getDialect(), start, end);
cacheResult(list);
if (useFinderCache) {
finderCache.putResult(finderPath, finderArgs, list);
}
} catch (Exception exception) {
if (useFinderCache) {
finderCache.removeResult(finderPath, finderArgs);
}
throw processException(exception);
} finally {
closeSession(session);
}
}
return list;
}
use of com.liferay.blade.samples.dspservicebuilder.model.Country in project liferay-blade-samples by liferay.
the class CountryPersistenceImpl method remove.
/**
* Removes the country with the primary key from the database. Also notifies the appropriate model listeners.
*
* @param primaryKey the primary key of the country
* @return the country that was removed
* @throws NoSuchCountryException if a country with the primary key could not be found
*/
@Override
public Country remove(Serializable primaryKey) throws NoSuchCountryException {
Session session = null;
try {
session = openSession();
Country country = (Country) session.get(CountryImpl.class, primaryKey);
if (country == null) {
if (_log.isDebugEnabled()) {
_log.debug(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
}
throw new NoSuchCountryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
}
return remove(country);
} catch (NoSuchCountryException noSuchEntityException) {
throw noSuchEntityException;
} catch (Exception exception) {
throw processException(exception);
} finally {
closeSession(session);
}
}
Aggregations