Java tutorial
/* * Copyright 2012 the original author or authors. * * 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 com.github.carlomicieli.service.hibernate; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; import com.github.carlomicieli.model.Team; import com.github.carlomicieli.service.TeamDAO; import com.github.carlomicieli.service.TeamService; /** * The Hibernate implementation for the teams service. * @author Carlo P. Micieli * */ @Service("teamService") @Transactional(readOnly = true) public class TeamServiceImpl implements TeamService { private @Autowired TeamDAO teamDAO; public TeamServiceImpl() { } /** * Add a new team to the repository. * @param team the new team. */ @Override @Transactional(propagation = Propagation.REQUIRED, readOnly = false) public void addTeam(Team team) { teamDAO.addTeam(team); } /** * Update a team in the repository. * @param team the modified team. */ @Override @Transactional(propagation = Propagation.REQUIRED, readOnly = false) public void updateTeam(Team team) { teamDAO.updateTeam(team); } /** * Delete a team from the repository. * @param team the team to delete. */ @Override @Transactional(propagation = Propagation.REQUIRED, readOnly = false) public void deleteTeam(Team team) { teamDAO.deleteTeam(team); } /** * Return a team from its unique id. * @param id the team unique id. * @return the team. */ @Override public Team getTeamById(long id) { return teamDAO.getTeamById(id); } /** * Return the list of the all team in the repository. * @return the list of teams. */ @Override public List<Team> getTeams() { return teamDAO.getTeams(); } /** * Return a team from its name. * @param name the team name. * @return the team. */ @Override public Team getTeamByName(String name) { return teamDAO.getTeamByName(name); } }