use of com.liferay.blade.samples.dspservicebuilder.exception.NoSuchCountryException 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