mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-17 13:05:49 +00:00
Add @Qualifier annotation for not-extended repositories implementations
This commit is contained in:
parent
4dd164d01b
commit
a0d68553e9
12 changed files with 31 additions and 1 deletions
|
@ -23,6 +23,7 @@ import java.util.Map;
|
|||
import javax.sql.DataSource;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.dao.EmptyResultDataAccessException;
|
||||
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
||||
|
@ -50,6 +51,7 @@ import org.springframework.stereotype.Repository;
|
|||
* @author Antoine Rey
|
||||
*/
|
||||
@Repository
|
||||
@Qualifier("OwnerRepository")
|
||||
public class JdbcOwnerRepositoryImpl implements OwnerRepository {
|
||||
|
||||
private NamedParameterJdbcTemplate namedParameterJdbcTemplate;
|
||||
|
|
|
@ -22,6 +22,7 @@ import java.util.Map;
|
|||
import javax.sql.DataSource;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.dao.EmptyResultDataAccessException;
|
||||
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
||||
|
@ -47,6 +48,7 @@ import org.springframework.stereotype.Repository;
|
|||
* @author Mark Fisher
|
||||
*/
|
||||
@Repository
|
||||
@Qualifier("PetRepository")
|
||||
public class JdbcPetRepositoryImpl implements PetRepository {
|
||||
|
||||
private NamedParameterJdbcTemplate namedParameterJdbcTemplate;
|
||||
|
@ -59,7 +61,9 @@ public class JdbcPetRepositoryImpl implements PetRepository {
|
|||
|
||||
|
||||
@Autowired
|
||||
public JdbcPetRepositoryImpl(DataSource dataSource, OwnerRepository ownerRepository, VisitRepository visitRepository) {
|
||||
public JdbcPetRepositoryImpl(DataSource dataSource,
|
||||
@Qualifier("OwnerRepository") OwnerRepository ownerRepository,
|
||||
@Qualifier("VisitRepository") VisitRepository visitRepository) {
|
||||
this.namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(dataSource);
|
||||
|
||||
this.insertPet = new SimpleJdbcInsert(dataSource)
|
||||
|
|
|
@ -22,6 +22,7 @@ import java.util.Collection;
|
|||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
|
@ -43,6 +44,7 @@ import org.springframework.stereotype.Repository;
|
|||
* @author Michael Isvy
|
||||
*/
|
||||
@Repository
|
||||
@Qualifier("VetRepository")
|
||||
public class JdbcVetRepositoryImpl implements VetRepository {
|
||||
|
||||
private JdbcTemplate jdbcTemplate;
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
package org.springframework.samples.petclinic.repository.jdbc;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
|
||||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
||||
|
@ -42,6 +43,7 @@ import java.util.Map;
|
|||
* @author Michael Isvy
|
||||
*/
|
||||
@Repository
|
||||
@Qualifier("VisitRepository")
|
||||
public class JdbcVisitRepositoryImpl implements VisitRepository {
|
||||
|
||||
private NamedParameterJdbcTemplate jdbcTemplate;
|
||||
|
|
|
@ -21,6 +21,7 @@ import javax.persistence.EntityManager;
|
|||
import javax.persistence.PersistenceContext;
|
||||
import javax.persistence.Query;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.orm.hibernate3.support.OpenSessionInViewFilter;
|
||||
import org.springframework.samples.petclinic.model.Owner;
|
||||
import org.springframework.samples.petclinic.repository.OwnerRepository;
|
||||
|
@ -36,6 +37,7 @@ import org.springframework.stereotype.Repository;
|
|||
* @since 22.4.2006
|
||||
*/
|
||||
@Repository
|
||||
@Qualifier("OwnerRepository")
|
||||
public class JpaOwnerRepositoryImpl implements OwnerRepository {
|
||||
|
||||
@PersistenceContext
|
||||
|
|
|
@ -20,6 +20,7 @@ import java.util.List;
|
|||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContext;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.samples.petclinic.model.Pet;
|
||||
import org.springframework.samples.petclinic.model.PetType;
|
||||
import org.springframework.samples.petclinic.repository.PetRepository;
|
||||
|
@ -35,6 +36,7 @@ import org.springframework.stereotype.Repository;
|
|||
* @since 22.4.2006
|
||||
*/
|
||||
@Repository
|
||||
@Qualifier("PetRepository")
|
||||
public class JpaPetRepositoryImpl implements PetRepository {
|
||||
|
||||
@PersistenceContext
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
*/
|
||||
package org.springframework.samples.petclinic.repository.jpa;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.samples.petclinic.model.Vet;
|
||||
import org.springframework.samples.petclinic.repository.VetRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
@ -33,6 +34,7 @@ import java.util.Collection;
|
|||
* @since 22.4.2006
|
||||
*/
|
||||
@Repository
|
||||
@Qualifier("VetRepository")
|
||||
public class JpaVetRepositoryImpl implements VetRepository {
|
||||
|
||||
@PersistenceContext
|
||||
|
|
|
@ -21,6 +21,7 @@ import javax.persistence.EntityManager;
|
|||
import javax.persistence.PersistenceContext;
|
||||
import javax.persistence.Query;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.samples.petclinic.model.Visit;
|
||||
import org.springframework.samples.petclinic.repository.VisitRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
@ -37,6 +38,7 @@ import org.springframework.stereotype.Repository;
|
|||
* @since 22.4.2006
|
||||
*/
|
||||
@Repository
|
||||
@Qualifier("VisitRepository")
|
||||
public class JpaVisitRepositoryImpl implements VisitRepository {
|
||||
|
||||
@PersistenceContext
|
||||
|
|
|
@ -17,6 +17,7 @@ package org.springframework.samples.petclinic.repository.springdatajpa;
|
|||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.Repository;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
|
@ -29,6 +30,8 @@ import org.springframework.samples.petclinic.repository.OwnerRepository;
|
|||
* @author Michael Isvy
|
||||
* @since 15.1.2013
|
||||
*/
|
||||
|
||||
@Qualifier("OwnerRepository")
|
||||
public interface SpringDataOwnerRepository extends OwnerRepository, Repository<Owner, Integer> {
|
||||
|
||||
@Override
|
||||
|
|
|
@ -17,6 +17,7 @@ package org.springframework.samples.petclinic.repository.springdatajpa;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.Repository;
|
||||
|
@ -30,6 +31,8 @@ import org.springframework.samples.petclinic.repository.PetRepository;
|
|||
* @author Michael Isvy
|
||||
* @since 15.1.2013
|
||||
*/
|
||||
|
||||
@Qualifier("PetRepository")
|
||||
public interface SpringDataPetRepository extends PetRepository, Repository<Pet, Integer> {
|
||||
|
||||
@Override
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
*/
|
||||
package org.springframework.samples.petclinic.repository.springdatajpa;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.data.repository.Repository;
|
||||
import org.springframework.samples.petclinic.model.Vet;
|
||||
import org.springframework.samples.petclinic.repository.VetRepository;
|
||||
|
@ -25,5 +26,7 @@ import org.springframework.samples.petclinic.repository.VetRepository;
|
|||
* @author Michael Isvy
|
||||
* @since 15.1.2013
|
||||
*/
|
||||
|
||||
@Qualifier("VetRepository")
|
||||
public interface SpringDataVetRepository extends VetRepository, Repository<Vet, Integer> {
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
*/
|
||||
package org.springframework.samples.petclinic.repository.springdatajpa;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.data.repository.Repository;
|
||||
import org.springframework.samples.petclinic.model.Visit;
|
||||
import org.springframework.samples.petclinic.repository.VisitRepository;
|
||||
|
@ -25,5 +26,7 @@ import org.springframework.samples.petclinic.repository.VisitRepository;
|
|||
* @author Michael Isvy
|
||||
* @since 15.1.2013
|
||||
*/
|
||||
|
||||
@Qualifier("VisitRepository")
|
||||
public interface SpringDataVisitRepository extends VisitRepository, Repository<Visit, Integer> {
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue