Java tutorial
/* Copyright 2006 - 2010 Under Dusken Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package no.dusken.aranea.service; import no.dusken.aranea.model.ExternalPage; import org.springframework.dao.DataAccessException; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Isolation; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @Service("externalPageService") @Transactional(propagation = Propagation.SUPPORTS, isolation = Isolation.DEFAULT, readOnly = true) public class ExternalPageServiceImpl extends AbstractPageServiceImpl<ExternalPage> implements ExternalPageService { public ExternalPageServiceImpl() { super(ExternalPage.class); } public List<ExternalPage> getExternalPagesBySite(String site) { List<ExternalPage> list = Collections.emptyList(); try { Map<String, Object> map = new HashMap<String, Object>(); map.put("site", site); list = genericDao.getByNamedQuery("externalPage_by_site", map); } catch (DataAccessException dae) { log.info("Unable to get externalPages", dae); } return list; } public List<ExternalPage> getPages(int offset, int number) { List<ExternalPage> list = Collections.emptyList(); try { list = genericDao.getByNamedQuery("externalPage_all", null, offset, number); } catch (DataAccessException dae) { log.info("Unable to get pages", dae); } return list; } public List<ExternalPage> getPublishedPages(int offset, int number) { List<ExternalPage> list = Collections.emptyList(); try { list = genericDao.getByNamedQuery("externalPage_all_published", null, offset, number); } catch (DataAccessException dae) { log.info("Unable to get pages", dae); } return list; } }