spring-transactions

Spring transactional package-private method

拈花ヽ惹草 提交于 2019-12-13 12:10:14
问题 I have a Spring MVC app with all logic related to a single business concern within a single Java package (controller, service, repository, DTO and resource). I enforce this by making all methods across presentation, service and persistence layers package-private (no interfaces are used). NB: layer separation is enforced with Maven modules with optional dependencies (presentation layer does not see persistence layer). However, the repository shall also be @Transactional , and using Spring

Populating H2 database with Spring and jdbc DataSourceTransactionManager

和自甴很熟 提交于 2019-12-13 06:46:32
问题 I am trying to use H2 embedded database with script config to create and load database during test. It works fine but when I tried to add transaction support for my database interactions I am getting error during context initialization. Here is my spring config: <bean id="dbcpDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="org.h2.Driver" /> <property name="url" value="jdbc:h2:mem:embeddedH2Database;MODE=Oracle;DB

Cannot configure @Transaction to work with Spring Data Neo4j

若如初见. 提交于 2019-12-13 06:02:02
问题 I'm trying to move away from manually-managed transactions to annotation based transactions in my Neo4j application. I've prepared annotation-based Spring configuration file: @Configuration @EnableNeo4jRepositories("xxx.yyy.neo4jplanetspersistence.repositories") @ComponentScan(basePackages = "xxx.yyy") @EnableTransactionManagement public class SpringDataConfiguration extends Neo4jConfiguration implements TransactionManagementConfigurer{ public SpringDataConfiguration() { super();

JPA cache behaviour when invoke count() method on Spring Data JPA Repository

大城市里の小女人 提交于 2019-12-13 03:55:43
问题 I'm writing a transactional junit-based IT test for Spring Data JPA repository. To check number of rows in table I use side JDBCTemplate. I notice, that in transactional context invoking of org.springframework.data.repository.CrudRepository#save(S) doesn't take effect. SQL insert in not performed, number of rows in table is not increased. But If I invoke org.springframework.data.repository.CrudRepository#count after the save(S) then SQL insert is performed and number of rows is increased. I

How do I override the default isolation level when using the Transaction attribute in Spring.Net

我的未来我决定 提交于 2019-12-13 02:03:06
问题 When using the Transaction() attribute on a method the default isolation level is ReadCommitted. What I want to do is set the default isolation level to ReadUncommitted in the Spring.NET config ( so as not to modify all the Transaction attribute definitions that exist currently) How do I do it ? Can it be done with Spring.NET 1.2 ? I've tried to follow the documentation using tx:advice etc to no avail. I've even stepped in to the code of Spring with Reflector but all I seem to understand from

Multiple transaction managers - Selecting a one at runtime - Spring

柔情痞子 提交于 2019-12-13 01:34:50
问题 I am using Spring to configure transactions in my application. I have two transaction managers defined for two RabbitMQ servers. .... @Bean(name = "devtxManager") public PlatformTransactionManager devtxManager() { return new RabbitTransactionManager(devConnectionFactory()); } @Bean(name = "qatxManager") public PlatformTransactionManager qatxManager() { return new RabbitTransactionManager(qaConnectionFactory()); } @Bean public ConnectionFactory devConnectionFactory() { CachingConnectionFactory

Multiple transaction managers in spring and select one at runtime

穿精又带淫゛_ 提交于 2019-12-12 23:04:29
问题 For each client, I have separate databases but business logic and tables are same for each client. I want common service and dao layer for each client. In dao, I select datasource based on logged user client. In @Transactional , I have to pass bean id of transaction manager. How to make common service layer with @Transactional annotation. Same question is here Multiple transaction managers - Selecting a one at runtime - Spring Choose between muliple transaction managers at runtime but nobody

Alternative of @Transactional annotation

不羁的心 提交于 2019-12-12 15:10:17
问题 What is the alternative of rollback transaction in spring except @Transactional annotation. I have used this annotation but i want the way by which i can rollback transaction in catch block. Is there any way? Thanx in advance. 回答1: Here is a draft: public class SomeService implements SomeInterface { private SomeDao thisDaoWrapsJdbcTemplate; private PlatformTransactionManager transactionManager; public void setTransactionManager( PlatformTransactionManager transactionManager ) { this

How to obtain Spring transaction manager instance?

别来无恙 提交于 2019-12-12 13:22:26
问题 I use annotations to mark methods which should be executed in a transaction. But, in one place I need to do transactionManager.rollback() manually, without annotation. How can I obtain transactionManager object? 回答1: If you want to rollback the current transaction, you may use TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); Note that it doesn't rollback the transaction immediately - it sets the "rollback only" status, so transaction will be rolled back during attempt to

SimpleMessageListenerContainer is continuously consuming after TransactionSystemException

爱⌒轻易说出口 提交于 2019-12-12 03:48:23
问题 I don't want the SimpleMessageListenerContainer to continuously consume the messages when my Transaction marked as rollback. I didn't add listener-container in my configuration file and trying to rethrow the AmqpRejectAndDontRequeueException . It is not working. Here is my codebase: @Transactional public class MySecondService { @Resource private MySecondRepository mySecondRepository; @Transactional(propagation = Propagation.REQUIRED) @ServiceActivator(inputChannel = "my-first-servie-output