Search in sources :

Example 1 with NoSuchRegionException

use of com.liferay.blade.samples.jndiservicebuilder.exception.NoSuchRegionException in project liferay-blade-samples by liferay.

the class RegionPersistenceImpl method remove.

/**
 * Removes the region with the primary key from the database. Also notifies the appropriate model listeners.
 *
 * @param primaryKey the primary key of the region
 * @return the region that was removed
 * @throws NoSuchRegionException if a region with the primary key could not be found
 */
@Override
public Region remove(Serializable primaryKey) throws NoSuchRegionException {
    Session session = null;
    try {
        session = openSession();
        Region region = (Region) session.get(RegionImpl.class, primaryKey);
        if (region == null) {
            if (_log.isDebugEnabled()) {
                _log.debug(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
            }
            throw new NoSuchRegionException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
        }
        return remove(region);
    } catch (NoSuchRegionException nsee) {
        throw nsee;
    } catch (Exception e) {
        throw processException(e);
    } finally {
        closeSession(session);
    }
}
Also used : Region(com.liferay.blade.samples.jndiservicebuilder.model.Region) NoSuchRegionException(com.liferay.blade.samples.jndiservicebuilder.exception.NoSuchRegionException) RegionImpl(com.liferay.blade.samples.jndiservicebuilder.model.impl.RegionImpl) NoSuchRegionException(com.liferay.blade.samples.jndiservicebuilder.exception.NoSuchRegionException) Session(com.liferay.portal.kernel.dao.orm.Session)

Aggregations

NoSuchRegionException (com.liferay.blade.samples.jndiservicebuilder.exception.NoSuchRegionException)1 Region (com.liferay.blade.samples.jndiservicebuilder.model.Region)1 RegionImpl (com.liferay.blade.samples.jndiservicebuilder.model.impl.RegionImpl)1 Session (com.liferay.portal.kernel.dao.orm.Session)1