I'm using Spring Boot with Solr.
I can see Spring-tx in my resolved dependencies.
When I call a @Transactional
annotated method in a Spring bean,
a) at runtime, i don't see any signs of it being wrapped in any transaction management proxy, and
b) when the method throws a RuntimeException
the data is not rolledback.
The email/phone repositories and just interfaces that extend
org.springframework.data.solr.repository.SolrCrudRepository
What am i missing?
At have the method annotated @Transactional
in both the interface and the implementation, just in case ;-)
public interface MyServiceInterface {
@Transactional
public CreateDetailsResponse createAllDetails(
final CreateDetailsRequest createDetailsRequest) throws BusinessException;
}
public class MyService implements MyServiceInterface {
@Autowired
private EmailRepository emailRepository;
@Autowired
private EmailRepository phoneRepository;
@Transactional
public CreateDetailsResponse createAllDetails(
final CreateDetailsRequest createDetailsRequest) throws BusinessException {
//method below calls emailRepository.save(emailDocument)
saveEmail();
//method below is supposed to call phoneRepository.save(phoneDocument)
//but throws RuntimeException before save is called
savePhone();
}
//...
}
@Configuration
@EnableSolrRepositories(basePackages = "com.....repository", multicoreSupport = true,
considerNestedRepositories = true, repositoryBaseClass = SoftCommitSimpleSolrRepository.class)
@EnableAutoConfiguration
public class ConsumersServiceConfiguration {
//...
@Bean
public MyServiceInterface myService() {
return new MyService();
}
}
Supposedly Solr supports transactions: