spring-transactions

Issue with @Transactional annotations in Spring JPA

只谈情不闲聊 提交于 2019-12-06 15:57:44
I have a doubt related to transactions within transactions. For background, I have a School entity object which has Set of Students entity object mapped to it. I am using Spring Data JPA which is taking care of all the crud operations. I have a SchoolManagementService class which has @Transactional(readonly=true) set at the class level and for all updating methods I am using @Transactional over them. In my SchoolManagementService class I have a method deleteStudents(List) which I have marked as @Transactional. In this method I am calling StudentsRepository.delete(studentId) again and again. I

Hibernate transactions does not start until the MVC request is done

南笙酒味 提交于 2019-12-06 14:37:57
问题 I am using spring MVC 3 and Hibernate 3.6, with Spring tx to manage the hibernate transactions, Now I am doing an ajax request to a controller that when the controller returns a value I navigate to another page, and i keep checking the controller till the value is returned. This controllers method invocation also have some database transactions to do, and what I am trying to do is to navigate when every thing is finished and the database tx is done and all is good, but what happens is that

Spring + Websphere 8.5: Unable to lookup JNDI name [java:comp/websphere/ExtendedJTATransaction]

家住魔仙堡 提交于 2019-12-06 14:26:17
There is a Websphere AS 8.5 where runs XA Datasource. Also there is a Spring application which must work in this environment and connect to the datasource. An application context is loaded by a servlet and the application uses RmiExporters to provide RMI access to some services (which are shared in the separate thread) and all DAOs' methods are marked with @Transactional . If I try to write something to the database from the main thread (e.g. during initialization of any class), it works properly. But if I try to write (or read with HQL SELECT-query) something via RMI invokation I see an

Spring4 + Hibernate4 + JTA Write Operations Fail

杀马特。学长 韩版系。学妹 提交于 2019-12-06 08:36:30
I am migrating a legacy Spring 3, Hibernate 3, JTA on JBoss 5 application to the latest versions (Spring 4.1.0.RELEASE, Hibernate 4.3.6.Final, JBoss Wildfly 8.1). It seems that Spring 4.1.0.RELEASE and Hibernate 4.3.6.Final do NOT work together in supporting transactions for write operations with the LocalSessionFactoryBean and the HibernateTransactionManager as configured below. Read-only get operations appear to be working ok. To migrate, org.springframework.orm. hibernate3 .support.HibernateDaoSupport has been updated to org.springframework.orm. hibernate4 .support.HibernateDaoSupport. The

noRollbackFor not always working on unchecked exceptions (not a duplicate)

浪尽此生 提交于 2019-12-06 06:01:07
I've seen a lot of similar questions but they are usually just tangential to mine. Here is my code. @Override //class implements interface //can also add "rollbackFor = OutOfMemoryError.class" here, to no avail @Transactional(noRollbackFor = IllegalArgumentException.class) public ReportTemplate getByCode(final String code) //throws IllegalArgumentException - see question text { if(code == null) { throw new IllegalArgumentException("ss"); } } Consumer (non-transactional) calls this method via autowired interface. Despite noRollbackFor the transaction (consisting of this method alone) gets

Differences in behaviour of REQUIRES_NEW and NESTED propagation in Spring transactions

走远了吗. 提交于 2019-12-06 02:38:49
问题 Preface First of all: It is not duplicate of Differences between requires_new and nested propagation in Spring transactions - I read it but I didn't found answer to my question Question: After reading topic I mentioned I understood that main difference between propagation levels in count of physical transactions: 2 db transactions- for REQUIRES_NEW for outer and for inner method 1 db transaction - for NESTED for outer and for inner method. It will not work if underlying database doesn't

Understanding transaction session with lazy loading in Spring JPA Hibernate

南楼画角 提交于 2019-12-05 20:51:22
I would like to get some clarification regarding lazy loading and session boundaries etc. My code structure is as follows @Entity class A { .... @OneToOne(fetch=LAZY) private B b; .. } @Entity class B { private id; private name; } @Transactional(SUPPORTS) ADao { A findById(int id); } @Transactional(SUPPORTS) LayerDB { A getAForId(int i) { return adao.findById(i); } } //Note that there is no transactional attribute here LayerB { public boolean doSomethingWithAandB(int aId) { A a = LayerDB.getAForId(aId); if(a.getB().getName().equals("HIGH")) return true; return false; } } //start transaction

Spring boot @Transactional

我们两清 提交于 2019-12-05 20:35:15
Does spring boot automatically add @Transactional annotation at controller layer? I tried putting @Transactional at service layer but it seems that the controller layer is overriding the annotation. I have this config <tx:advice id="txAdvice" transaction-manager="transactionManager"> <tx:attributes> <tx:method name="find*" read-only="true" isolation="READ_COMMITTED" propagation="NOT_SUPPORTED" /> <tx:method name="load*" read-only="true" isolation="READ_COMMITTED" propagation="NOT_SUPPORTED" /> <tx:method name="get*" read-only="true" isolation="READ_COMMITTED" propagation="NOT_SUPPORTED" /> <tx

Attempt to update step execution id=1 with wrong version (2), where current version is 1

岁酱吖の 提交于 2019-12-05 19:03:52
问题 Im using SpringBatch 2.1.7 release core and Infrastructure jars to read a CSV file and save it to DB. Integrated my code with Spring quartz scheduler to run for every minute, The Batch is working fine with reading and writing but its failing with the error "org.springframework.dao.OptimisticLockingFailureException: Attempt to update step execution id=1 with wrong version (2), where current version is 1" due to Tx conflicts. Please suggest how can i resolve this issue. 回答1: I had this same

Grails integration tests and transactions

有些话、适合烂在心里 提交于 2019-12-05 06:30:04
I don't get why this integration test fails. I can get the test to pass by either removing the @Transactional(propagation = Propagation.REQUIRES_NEW) annotation above the service method, OR by setting transactional = false in the Integration Test I realize that the integration test itself is running in a transaction, and that's why I've got the annotation on the service method. class DbTests extends GrailsUnitTestCase { boolean transactional = true def customerService void testTransactionsCommit() { def orderIds = [1, 2, 3] orderIds.each { // lets make sure they all start out as Active def