Search in sources :

Example 1 with NoSuchCountryException

use of com.liferay.blade.samples.jdbcservicebuilder.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 nsee) {
        throw nsee;
    } catch (Exception e) {
        throw processException(e);
    } finally {
        closeSession(session);
    }
}
Also used : CountryImpl(com.liferay.blade.samples.jdbcservicebuilder.model.impl.CountryImpl) Country(com.liferay.blade.samples.jdbcservicebuilder.model.Country) NoSuchCountryException(com.liferay.blade.samples.jdbcservicebuilder.exception.NoSuchCountryException) Session(com.liferay.portal.kernel.dao.orm.Session) NoSuchCountryException(com.liferay.blade.samples.jdbcservicebuilder.exception.NoSuchCountryException)

Aggregations

NoSuchCountryException (com.liferay.blade.samples.jdbcservicebuilder.exception.NoSuchCountryException)1 Country (com.liferay.blade.samples.jdbcservicebuilder.model.Country)1 CountryImpl (com.liferay.blade.samples.jdbcservicebuilder.model.impl.CountryImpl)1 Session (com.liferay.portal.kernel.dao.orm.Session)1