made sure @Transactional is not set on the Repository layer

This commit is contained in:
Mic 2013-02-13 09:37:42 +08:00
parent 4e91b4468e
commit c5ca72e80b
6 changed files with 6 additions and 22 deletions

View file

@ -23,7 +23,6 @@ import org.springframework.samples.petclinic.repository.OwnerRepository;
import org.springframework.samples.petclinic.repository.VisitRepository;
import org.springframework.samples.petclinic.util.EntityUtils;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
/**
* A simple JDBC-based implementation of the {@link OwnerRepository} interface.
@ -67,7 +66,6 @@ public class JdbcOwnerRepositoryImpl implements OwnerRepository {
* the {@link Pet Pets} and {@link Visit Visits} for the corresponding
* owners, if not already loaded.
*/
@Transactional(readOnly = true)
public Collection<Owner> findByLastName(String lastName) throws DataAccessException {
Map<String, Object> params = new HashMap<String, Object>();
params.put("lastName", lastName+"%");
@ -85,7 +83,6 @@ public class JdbcOwnerRepositoryImpl implements OwnerRepository {
* the {@link Pet Pets} and {@link Visit Visits} for the corresponding
* owner, if not already loaded.
*/
@Transactional(readOnly = true)
public Owner findById(int id) throws DataAccessException {
Owner owner;
try {
@ -122,9 +119,6 @@ public class JdbcOwnerRepositoryImpl implements OwnerRepository {
}
}
@Transactional
public void save(Owner owner) throws DataAccessException {
BeanPropertySqlParameterSource parameterSource = new BeanPropertySqlParameterSource(owner);
if (owner.isNew()) {
@ -139,11 +133,6 @@ public class JdbcOwnerRepositoryImpl implements OwnerRepository {
}
}
@Transactional(readOnly = true)
public Collection<PetType> getPetTypes() throws DataAccessException {
return this.namedParameterJdbcTemplate.query(
"SELECT id, name FROM types ORDER BY name", new HashMap<String,Object>(),

View file

@ -19,7 +19,6 @@ import org.springframework.samples.petclinic.model.Vet;
import org.springframework.samples.petclinic.repository.VetRepository;
import org.springframework.samples.petclinic.util.EntityUtils;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
/**
*
@ -49,7 +48,6 @@ public class JdbcVetRepositoryImpl implements VetRepository {
* @see org.springframework.samples.petclinic.model.service.ClinicService#findVets()
*/
@ManagedOperation
@Transactional(readOnly = true)
public void refreshVetsCache() throws DataAccessException {
synchronized (this.vets) {
this.logger.info("Refreshing vets cache");

View file

@ -42,13 +42,11 @@ public class ClinicServiceImpl implements ClinicService {
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);