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);
}
}
Aggregations