remove all the Override annotation which implements interface.

This commit is contained in:
yuyang 2015-03-14 19:01:43 +08:00
parent 6e96447931
commit 0cb14b045c
12 changed files with 1 additions and 31 deletions

View file

@ -77,7 +77,6 @@ public class JdbcOwnerRepositoryImpl implements OwnerRepository {
* the given name; also loads the {@link Pet Pets} and {@link Visit Visits} for the corresponding owners, if not * the given name; also loads the {@link Pet Pets} and {@link Visit Visits} for the corresponding owners, if not
* already loaded. * already loaded.
*/ */
@Override
public Collection<Owner> findByLastName(String lastName) throws DataAccessException { public Collection<Owner> findByLastName(String lastName) throws DataAccessException {
Map<String, Object> params = new HashMap<String, Object>(); Map<String, Object> params = new HashMap<String, Object>();
params.put("lastName", lastName + "%"); params.put("lastName", lastName + "%");
@ -94,7 +93,6 @@ public class JdbcOwnerRepositoryImpl implements OwnerRepository {
* Loads the {@link Owner} with the supplied <code>id</code>; also loads the {@link Pet Pets} and {@link Visit Visits} * Loads the {@link Owner} with the supplied <code>id</code>; also loads the {@link Pet Pets} and {@link Visit Visits}
* for the corresponding owner, if not already loaded. * for the corresponding owner, if not already loaded.
*/ */
@Override
public Owner findById(int id) throws DataAccessException { public Owner findById(int id) throws DataAccessException {
Owner owner; Owner owner;
try { try {
@ -130,7 +128,6 @@ public class JdbcOwnerRepositoryImpl implements OwnerRepository {
} }
} }
@Override
public void save(Owner owner) throws DataAccessException { public void save(Owner owner) throws DataAccessException {
BeanPropertySqlParameterSource parameterSource = new BeanPropertySqlParameterSource(owner); BeanPropertySqlParameterSource parameterSource = new BeanPropertySqlParameterSource(owner);
if (owner.isNew()) { if (owner.isNew()) {

View file

@ -71,7 +71,6 @@ public class JdbcPetRepositoryImpl implements PetRepository {
this.visitRepository = visitRepository; this.visitRepository = visitRepository;
} }
@Override
public List<PetType> findPetTypes() throws DataAccessException { public List<PetType> findPetTypes() throws DataAccessException {
Map<String, Object> params = new HashMap<String, Object>(); Map<String, Object> params = new HashMap<String, Object>();
return this.namedParameterJdbcTemplate.query( return this.namedParameterJdbcTemplate.query(
@ -80,7 +79,6 @@ public class JdbcPetRepositoryImpl implements PetRepository {
BeanPropertyRowMapper.newInstance(PetType.class)); BeanPropertyRowMapper.newInstance(PetType.class));
} }
@Override
public Pet findById(int id) throws DataAccessException { public Pet findById(int id) throws DataAccessException {
JdbcPet pet; JdbcPet pet;
try { try {
@ -104,7 +102,6 @@ public class JdbcPetRepositoryImpl implements PetRepository {
return pet; return pet;
} }
@Override
public void save(Pet pet) throws DataAccessException { public void save(Pet pet) throws DataAccessException {
if (pet.isNew()) { if (pet.isNew()) {
Number newKey = this.insertPet.executeAndReturnKey( Number newKey = this.insertPet.executeAndReturnKey(

View file

@ -58,7 +58,6 @@ public class JdbcVetRepositoryImpl implements VetRepository {
* *
* @see org.springframework.samples.petclinic.model.service.ClinicService#shouldFindVets() * @see org.springframework.samples.petclinic.model.service.ClinicService#shouldFindVets()
*/ */
@Override
public Collection<Vet> findAll() throws DataAccessException { public Collection<Vet> findAll() throws DataAccessException {
List<Vet> vets = new ArrayList<Vet>(); List<Vet> vets = new ArrayList<Vet>();
// Retrieve the list of all vets. // Retrieve the list of all vets.

View file

@ -61,7 +61,6 @@ public class JdbcVisitRepositoryImpl implements VisitRepository {
} }
@Override
public void save(Visit visit) throws DataAccessException { public void save(Visit visit) throws DataAccessException {
if (visit.isNew()) { if (visit.isNew()) {
Number newKey = this.insertVisit.executeAndReturnKey( Number newKey = this.insertVisit.executeAndReturnKey(
@ -88,7 +87,6 @@ public class JdbcVisitRepositoryImpl implements VisitRepository {
.addValue("pet_id", visit.getPet().getId()); .addValue("pet_id", visit.getPet().getId());
} }
@Override
public List<Visit> findByPetId(Integer petId) { public List<Visit> findByPetId(Integer petId) {
final List<Visit> visits = this.jdbcTemplate.query( final List<Visit> visits = this.jdbcTemplate.query(
"SELECT id, visit_date, description FROM visits WHERE pet_id=?", "SELECT id, visit_date, description FROM visits WHERE pet_id=?",

View file

@ -58,7 +58,6 @@ public class JpaOwnerRepositoryImpl implements OwnerRepository {
return query.getResultList(); return query.getResultList();
} }
@Override
public Owner findById(int id) { public Owner findById(int id) {
// using 'join fetch' because a single query should load both owners and pets // using 'join fetch' because a single query should load both owners and pets
// using 'left join fetch' because it might happen that an owner does not have pets yet // using 'left join fetch' because it might happen that an owner does not have pets yet
@ -68,7 +67,6 @@ public class JpaOwnerRepositoryImpl implements OwnerRepository {
} }
@Override
public void save(Owner owner) { public void save(Owner owner) {
if (owner.getId() == null) { if (owner.getId() == null) {
this.em.persist(owner); this.em.persist(owner);

View file

@ -40,18 +40,15 @@ public class JpaPetRepositoryImpl implements PetRepository {
@PersistenceContext @PersistenceContext
private EntityManager em; private EntityManager em;
@Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public List<PetType> findPetTypes() { public List<PetType> findPetTypes() {
return this.em.createQuery("SELECT ptype FROM PetType ptype ORDER BY ptype.name").getResultList(); return this.em.createQuery("SELECT ptype FROM PetType ptype ORDER BY ptype.name").getResultList();
} }
@Override
public Pet findById(int id) { public Pet findById(int id) {
return this.em.find(Pet.class, id); return this.em.find(Pet.class, id);
} }
@Override
public void save(Pet pet) { public void save(Pet pet) {
if (pet.getId() == null) { if (pet.getId() == null) {
this.em.persist(pet); this.em.persist(pet);

View file

@ -41,7 +41,6 @@ public class JpaVetRepositoryImpl implements VetRepository {
private EntityManager em; private EntityManager em;
@Override
@Cacheable(value = "vets") @Cacheable(value = "vets")
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public Collection<Vet> findAll() { public Collection<Vet> findAll() {

View file

@ -43,7 +43,6 @@ public class JpaVisitRepositoryImpl implements VisitRepository {
private EntityManager em; private EntityManager em;
@Override
public void save(Visit visit) { public void save(Visit visit) {
if (visit.getId() == null) { if (visit.getId() == null) {
this.em.persist(visit); this.em.persist(visit);
@ -54,7 +53,6 @@ public class JpaVisitRepositoryImpl implements VisitRepository {
} }
@Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public List<Visit> findByPetId(Integer petId) { public List<Visit> findByPetId(Integer petId) {
Query query = this.em.createQuery("SELECT visit FROM Visit v where v.pets.id= :id"); Query query = this.em.createQuery("SELECT visit FROM Visit v where v.pets.id= :id");

View file

@ -31,11 +31,9 @@ import org.springframework.samples.petclinic.repository.OwnerRepository;
*/ */
public interface SpringDataOwnerRepository extends OwnerRepository, Repository<Owner, Integer> { public interface SpringDataOwnerRepository extends OwnerRepository, Repository<Owner, Integer> {
@Override @Query("SELECT DISTINCT owner FROM Owner owner left join fetch owner.pets WHERE owner.lastName LIKE :lastName%")
@Query("SELECT DISTINCT owner FROM Owner owner left join fetch owner.pets WHERE owner.lastName LIKE :lastName%")
public Collection<Owner> findByLastName(@Param("lastName") String lastName); public Collection<Owner> findByLastName(@Param("lastName") String lastName);
@Override
@Query("SELECT owner FROM Owner owner left join fetch owner.pets WHERE owner.id =:id") @Query("SELECT owner FROM Owner owner left join fetch owner.pets WHERE owner.id =:id")
public Owner findById(@Param("id") int id); public Owner findById(@Param("id") int id);
} }

View file

@ -32,7 +32,6 @@ import org.springframework.samples.petclinic.repository.PetRepository;
*/ */
public interface SpringDataPetRepository extends PetRepository, Repository<Pet, Integer> { public interface SpringDataPetRepository extends PetRepository, Repository<Pet, Integer> {
@Override
@Query("SELECT ptype FROM PetType ptype ORDER BY ptype.name") @Query("SELECT ptype FROM PetType ptype ORDER BY ptype.name")
List<PetType> findPetTypes() throws DataAccessException; List<PetType> findPetTypes() throws DataAccessException;
} }

View file

@ -54,51 +54,43 @@ public class ClinicServiceImpl implements ClinicService {
this.visitRepository = visitRepository; this.visitRepository = visitRepository;
} }
@Override
@Transactional(readOnly = true) @Transactional(readOnly = true)
public Collection<PetType> findPetTypes() throws DataAccessException { public Collection<PetType> findPetTypes() throws DataAccessException {
return petRepository.findPetTypes(); return petRepository.findPetTypes();
} }
@Override
@Transactional(readOnly = true) @Transactional(readOnly = true)
public Owner findOwnerById(int id) throws DataAccessException { public Owner findOwnerById(int id) throws DataAccessException {
return ownerRepository.findById(id); return ownerRepository.findById(id);
} }
@Override
@Transactional(readOnly = true) @Transactional(readOnly = true)
public Collection<Owner> findOwnerByLastName(String lastName) throws DataAccessException { public Collection<Owner> findOwnerByLastName(String lastName) throws DataAccessException {
return ownerRepository.findByLastName(lastName); return ownerRepository.findByLastName(lastName);
} }
@Override
@Transactional @Transactional
public void saveOwner(Owner owner) throws DataAccessException { public void saveOwner(Owner owner) throws DataAccessException {
ownerRepository.save(owner); ownerRepository.save(owner);
} }
@Override
@Transactional @Transactional
public void saveVisit(Visit visit) throws DataAccessException { public void saveVisit(Visit visit) throws DataAccessException {
visitRepository.save(visit); visitRepository.save(visit);
} }
@Override
@Transactional(readOnly = true) @Transactional(readOnly = true)
public Pet findPetById(int id) throws DataAccessException { public Pet findPetById(int id) throws DataAccessException {
return petRepository.findById(id); return petRepository.findById(id);
} }
@Override
@Transactional @Transactional
public void savePet(Pet pet) throws DataAccessException { public void savePet(Pet pet) throws DataAccessException {
petRepository.save(pet); petRepository.save(pet);
} }
@Override
@Transactional(readOnly = true) @Transactional(readOnly = true)
@Cacheable(value = "vets") @Cacheable(value = "vets")
public Collection<Vet> findVets() throws DataAccessException { public Collection<Vet> findVets() throws DataAccessException {

View file

@ -47,12 +47,10 @@ public class PetTypeFormatter implements Formatter<PetType> {
this.clinicService = clinicService; this.clinicService = clinicService;
} }
@Override
public String print(PetType petType, Locale locale) { public String print(PetType petType, Locale locale) {
return petType.getName(); return petType.getName();
} }
@Override
public PetType parse(String text, Locale locale) throws ParseException { public PetType parse(String text, Locale locale) throws ParseException {
Collection<PetType> findPetTypes = this.clinicService.findPetTypes(); Collection<PetType> findPetTypes = this.clinicService.findPetTypes();
for (PetType type : findPetTypes) { for (PetType type : findPetTypes) {