spring-transactions

Upgraded from Spring 4.1.6 to 4.2.4 and suddenly getting TransactionRequiredException

时光总嘲笑我的痴心妄想 提交于 2019-12-21 20:53:03
问题 I have upgraded to latest Spring version from 4.1.6.Release to 4.2.4.Release and suddenly all what has functioned smoothly before, now throws the following exception. javax.persistence.TransactionRequiredException: No EntityManager with actual transaction available for current thread - cannot reliably process 'persist' call at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:277) ~[na:4.2.4.RELEASE] at com.sun

Isolation level READ_UNCOMMITTED not working

谁说我不能喝 提交于 2019-12-21 05:14:25
问题 I am trying to understand isolation levels of Spring transactions. Here is the example I am using: @Component public class BookShop { private Object lockObj = new Object(); @Autowired private BookDao bookDao; @Transactional public void increaseStock(int isbn, int increment){ String threadName = Thread.currentThread().getName(); synchronized (lockObj) { Book book = bookDao.findByIsbn(isbn); System.out.println(threadName+" about to increment the stock"); bookDao.updateStock(book, 5); } System

Does the Spring transaction manager bind a connection to a thread?

故事扮演 提交于 2019-12-21 04:21:27
问题 I found the following thread: How exactly JdbcTemplate with TransactionManager works together? The first sentence of that: As far as I understood DataSourceTransactionManager binds a JDBC connection from the specified DataSource to the current thread, allowing for one thread-bound Connection per DataSource. If it's a pool of connections, it will take one of the available connections. ... is exactly what I want to know. When using a transaction manager, do you end up with each thread having it

java.lang.ClassCastException: com.sun.proxy.$Proxy0 cannot be cast to org.andrea.myexample.myDeclarativeTransactionSpring.StudentJDBCTemplate

余生长醉 提交于 2019-12-21 02:48:09
问题 I am trying to implement this tutorial about Declarative Transaction in Spring Framework application but don't work because when I try to execute the MainApp class to test the application behavior I obtain an error: http://www.tutorialspoint.com/spring/declarative_management.htm So I have the StudentDAO interface in wich I only define the CRUD method that I want: package org.andrea.myexample.myDeclarativeTransactionSpring; import java.util.List; import javax.sql.DataSource; /** Interfaccia

What is the scope of @EnableTransactionManagement?

半腔热情 提交于 2019-12-20 09:45:51
问题 I'm trying to understand where is the right place to put @EnableTransactionManagement annotation in case of multiple JavaConfig contexts? Consider following scenario: I have JPA config in JPAConfig.java and AppConfig.java with set of service beans. Then I compose overall application config in RootConfig.java. I define transaction manager within JPAConfig.java as well as enable scanning for JPA repositories - as those expose transactional behavior, I put @EnableTransactionManagement over

How to rollback a transaction if the POST response could not be delivered

可紊 提交于 2019-12-20 03:26:09
问题 Using Spring MVC, assume I have implemented a controller that handles a POST request, performs a database operation inside a transaction, and returns a result in the response body. Here is the controller and service layer: @RestController @RequiredArgsConstructor public class SomeController { private final SomeService someService; @PostMapping("/something") public SomeResult postSomething(Something something) { return someService.handle(something); } } @Service @RequiredArgsConstructor public

No transactional EntityManager available

和自甴很熟 提交于 2019-12-19 09:17:13
问题 I am new to the jpa and spring world and I am currently doing some unit test on a simple method but keep getting this error message only when I run my test class in unit test mode: java.lang.IllegalStateException: No transactional EntityManager available at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:223) at $Proxy19.unwrap(Unknown Source) at com.gemstone.integration.PersonDao.getPersonByUserNamePassword

Spring and Hibernate suddenly set the transaction to readonly

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-18 19:18:23
问题 We have an application running on JBoss 4.2.3, using Spring 2.5.2 and Hibernate 3.2.6.ga. This is running on Linux JEE01 2.6.16.60-0.54.5-smp, using its own user. Writing to a Oracle 10G database on another machine. We're using a standard view -> service -> dao layering. Where each dao is annotated with @Repository. This is all running 24/7 without many problems, but every several days and sometimes a couple of times in one day the whole system goes into a bad state where nothing can be

Spring and Hibernate suddenly set the transaction to readonly

倖福魔咒の 提交于 2019-12-18 19:18:15
问题 We have an application running on JBoss 4.2.3, using Spring 2.5.2 and Hibernate 3.2.6.ga. This is running on Linux JEE01 2.6.16.60-0.54.5-smp, using its own user. Writing to a Oracle 10G database on another machine. We're using a standard view -> service -> dao layering. Where each dao is annotated with @Repository. This is all running 24/7 without many problems, but every several days and sometimes a couple of times in one day the whole system goes into a bad state where nothing can be

@Async and @Transactional: not working

时光毁灭记忆、已成空白 提交于 2019-12-18 13:05:11
问题 Please see code. When I called the method @Async loadMarkUpPCT(), data is NOT committed into the table. It behaves as if it's non-tractional. When I removed @Async from loadMarkUpPCT (Class 1), i.e. non-async, then data is committed and OK as expected: transactional) I was expecting to have the same result with @Async and @Transactional but it's NOT. Please explain or what did I do wrong? Edited: I just edited to post the code + log Flow-wise: AppDataLoaderController calls