mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-17 21:35:50 +00:00
remove all the Override annotation which implements interface.
This commit is contained in:
parent
6e96447931
commit
0cb14b045c
12 changed files with 1 additions and 31 deletions
|
@ -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
|
||||
* already loaded.
|
||||
*/
|
||||
@Override
|
||||
public Collection<Owner> findByLastName(String lastName) throws DataAccessException {
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
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}
|
||||
* for the corresponding owner, if not already loaded.
|
||||
*/
|
||||
@Override
|
||||
public Owner findById(int id) throws DataAccessException {
|
||||
Owner owner;
|
||||
try {
|
||||
|
@ -130,7 +128,6 @@ public class JdbcOwnerRepositoryImpl implements OwnerRepository {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(Owner owner) throws DataAccessException {
|
||||
BeanPropertySqlParameterSource parameterSource = new BeanPropertySqlParameterSource(owner);
|
||||
if (owner.isNew()) {
|
||||
|
|
|
@ -71,7 +71,6 @@ public class JdbcPetRepositoryImpl implements PetRepository {
|
|||
this.visitRepository = visitRepository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PetType> findPetTypes() throws DataAccessException {
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
return this.namedParameterJdbcTemplate.query(
|
||||
|
@ -80,7 +79,6 @@ public class JdbcPetRepositoryImpl implements PetRepository {
|
|||
BeanPropertyRowMapper.newInstance(PetType.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pet findById(int id) throws DataAccessException {
|
||||
JdbcPet pet;
|
||||
try {
|
||||
|
@ -104,7 +102,6 @@ public class JdbcPetRepositoryImpl implements PetRepository {
|
|||
return pet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(Pet pet) throws DataAccessException {
|
||||
if (pet.isNew()) {
|
||||
Number newKey = this.insertPet.executeAndReturnKey(
|
||||
|
|
|
@ -58,7 +58,6 @@ public class JdbcVetRepositoryImpl implements VetRepository {
|
|||
*
|
||||
* @see org.springframework.samples.petclinic.model.service.ClinicService#shouldFindVets()
|
||||
*/
|
||||
@Override
|
||||
public Collection<Vet> findAll() throws DataAccessException {
|
||||
List<Vet> vets = new ArrayList<Vet>();
|
||||
// Retrieve the list of all vets.
|
||||
|
|
|
@ -61,7 +61,6 @@ public class JdbcVisitRepositoryImpl implements VisitRepository {
|
|||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void save(Visit visit) throws DataAccessException {
|
||||
if (visit.isNew()) {
|
||||
Number newKey = this.insertVisit.executeAndReturnKey(
|
||||
|
@ -88,7 +87,6 @@ public class JdbcVisitRepositoryImpl implements VisitRepository {
|
|||
.addValue("pet_id", visit.getPet().getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Visit> findByPetId(Integer petId) {
|
||||
final List<Visit> visits = this.jdbcTemplate.query(
|
||||
"SELECT id, visit_date, description FROM visits WHERE pet_id=?",
|
||||
|
|
|
@ -58,7 +58,6 @@ public class JpaOwnerRepositoryImpl implements OwnerRepository {
|
|||
return query.getResultList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Owner findById(int id) {
|
||||
// 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
|
||||
|
@ -68,7 +67,6 @@ public class JpaOwnerRepositoryImpl implements OwnerRepository {
|
|||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void save(Owner owner) {
|
||||
if (owner.getId() == null) {
|
||||
this.em.persist(owner);
|
||||
|
|
|
@ -40,18 +40,15 @@ public class JpaPetRepositoryImpl implements PetRepository {
|
|||
@PersistenceContext
|
||||
private EntityManager em;
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<PetType> findPetTypes() {
|
||||
return this.em.createQuery("SELECT ptype FROM PetType ptype ORDER BY ptype.name").getResultList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pet findById(int id) {
|
||||
return this.em.find(Pet.class, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(Pet pet) {
|
||||
if (pet.getId() == null) {
|
||||
this.em.persist(pet);
|
||||
|
|
|
@ -41,7 +41,6 @@ public class JpaVetRepositoryImpl implements VetRepository {
|
|||
private EntityManager em;
|
||||
|
||||
|
||||
@Override
|
||||
@Cacheable(value = "vets")
|
||||
@SuppressWarnings("unchecked")
|
||||
public Collection<Vet> findAll() {
|
||||
|
|
|
@ -43,7 +43,6 @@ public class JpaVisitRepositoryImpl implements VisitRepository {
|
|||
private EntityManager em;
|
||||
|
||||
|
||||
@Override
|
||||
public void save(Visit visit) {
|
||||
if (visit.getId() == null) {
|
||||
this.em.persist(visit);
|
||||
|
@ -54,7 +53,6 @@ public class JpaVisitRepositoryImpl implements VisitRepository {
|
|||
}
|
||||
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<Visit> findByPetId(Integer petId) {
|
||||
Query query = this.em.createQuery("SELECT visit FROM Visit v where v.pets.id= :id");
|
||||
|
|
|
@ -31,11 +31,9 @@ import org.springframework.samples.petclinic.repository.OwnerRepository;
|
|||
*/
|
||||
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);
|
||||
|
||||
@Override
|
||||
@Query("SELECT owner FROM Owner owner left join fetch owner.pets WHERE owner.id =:id")
|
||||
public Owner findById(@Param("id") int id);
|
||||
}
|
||||
|
|
|
@ -32,7 +32,6 @@ import org.springframework.samples.petclinic.repository.PetRepository;
|
|||
*/
|
||||
public interface SpringDataPetRepository extends PetRepository, Repository<Pet, Integer> {
|
||||
|
||||
@Override
|
||||
@Query("SELECT ptype FROM PetType ptype ORDER BY ptype.name")
|
||||
List<PetType> findPetTypes() throws DataAccessException;
|
||||
}
|
||||
|
|
|
@ -54,51 +54,43 @@ public class ClinicServiceImpl implements ClinicService {
|
|||
this.visitRepository = visitRepository;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public Collection<PetType> findPetTypes() throws DataAccessException {
|
||||
return petRepository.findPetTypes();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public Owner findOwnerById(int id) throws DataAccessException {
|
||||
return ownerRepository.findById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public Collection<Owner> findOwnerByLastName(String lastName) throws DataAccessException {
|
||||
return ownerRepository.findByLastName(lastName);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void saveOwner(Owner owner) throws DataAccessException {
|
||||
ownerRepository.save(owner);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void saveVisit(Visit visit) throws DataAccessException {
|
||||
visitRepository.save(visit);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public Pet findPetById(int id) throws DataAccessException {
|
||||
return petRepository.findById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void savePet(Pet pet) throws DataAccessException {
|
||||
petRepository.save(pet);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
@Cacheable(value = "vets")
|
||||
public Collection<Vet> findVets() throws DataAccessException {
|
||||
|
|
|
@ -47,12 +47,10 @@ public class PetTypeFormatter implements Formatter<PetType> {
|
|||
this.clinicService = clinicService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String print(PetType petType, Locale locale) {
|
||||
return petType.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PetType parse(String text, Locale locale) throws ParseException {
|
||||
Collection<PetType> findPetTypes = this.clinicService.findPetTypes();
|
||||
for (PetType type : findPetTypes) {
|
||||
|
|
Loading…
Reference in a new issue