transactional

How to set isolation level in @Transactional “READ_UNCOMMITTED”. I am using EclipseLink 2.5.1-RC1

只愿长相守 提交于 2019-12-23 12:35:37
问题 I have a requirement to start new Transaction within an ongoing Transaction so that an exception in 2nd transaction will rollback only new transaction not the old one. This I am doing by setting propagation attribute in 2nd transaction like this: @Transactional(propagation = Propagation.REQUIRES_NEW) This created a new Transaction, but the new Transaction needs to read some uncommitted data of the first transaction (dirty read), and also update that data. This I am trying to do by setting

Spring: automatic rollback on checked exceptions

与世无争的帅哥 提交于 2019-12-23 07:15:10
问题 One way to configure Spring to rollback on a non RuntimeExceptions is using @Transactional(rollbackFor=...) annotation on the service classes. The problem with this approach is that we need to define (rollbackFor=...) for almost all the service classes which seems really redundant. My question: Is there any way to configure a default behaviour for Spring transaction manager to rollback on a non RuntimeException whenever it happens without declaring it on every @Transactional annotation.

Spring Data JPA + Hibernate : catch block inside a Transactional method is never reached

走远了吗. 提交于 2019-12-23 05:57:07
问题 In our Spring Data JPA + Hibernate application, there are various methods having multiple JPA operations inside the same transaction - below is the code/configuration on one of the spring service methods. @Transactional(rollbackFor=MyAppException.class) public void updateCustomerprofile(String customerKey) throws MyAppException{ try{ CustomerId customerIdObj = customerIdRepository.findOne(customerKey); customerIdObj.setCreatedUser("<loggedin-user>"); // more logic here customerIdObj =

Spring @Transactional wont rollback after putting aspect around method

冷暖自知 提交于 2019-12-23 05:37:07
问题 I have two transactional methods one inside other. When around aspect is not set around methodA Transactional anotation work well. After calling methodA we call methodB, methodB write something in DB, then we return in methodA, throw an exception and then methodB roolback. But when I put my aspect around methodA, methodB wont rollback. I cant figure out what is happening there. I tried many combination of propagation attributes but none seems to work. Thanks in advance. I use Spring 2.5.4 I

Spring Transactional annotation, isolation not working for READ_UNCOMMITTED

人盡茶涼 提交于 2019-12-23 03:29:32
问题 I have a method in Java which is wrapped by a spring Transactional annotation. I have 2 operations inside, one is delete , another one is insert . My insertion statement have to rely on the first operation (which is the delete ), but now because of the first operation is not committed yet, my insertion fail (unique constraint). But this is funny that, usually within the same transaction, I should be able to read/see the uncommited operation in the same transaction (my old proprietary

Spring Hibernate - Could not obtain transaction-synchronized Session for current thread

本小妞迷上赌 提交于 2019-12-22 10:29:12
问题 Why am I posting this? After several hours of search / analysis / getting paranoid I would like to share my fault with you - I nailed down my cause of the problem. When did it happen? within the application server (in my case embedded tomcat) - tests had no problem on two specific @Services on which the methods got properly annotated with @Transactional What was not the problem? Missing @EnableTransactionManagement in the @Configuration Some weired AOP issue, eg having no default constructor

Hibernate, Spring, @Transactional - surround with try/catch?

风格不统一 提交于 2019-12-21 13:15:15
问题 Im working on developing a webapplication with Spring 3 and Hibernate 3.6. Ive got some questions to the @Transactional Annotation and the structure of the code. -> When I use @Transactional (transaction management with Spring), do I have to surround the @Transactional -annotated methods with try/catch when calling them? For example, when I got a method which loads, changes and returns then an object and I call it from another class: do I have to surround the call with try/catch? maybe

Spring @Transactional rollbackFor not working

爷,独闯天下 提交于 2019-12-20 02:52:37
问题 I have a code like below public abstract class AffltTransactionService implements IAffltTransactionService { .... @Override @Transactional public void processTransactions(List<? extends AffltTransaction> transactions) { for (AffltTransaction transaction : transactions) { if (transaction != null) { processTransaction(transaction); } } } private void processTransaction(AffltTransaction transaction) { try { processTransactionInternal(transaction); } catch (Exception exception) {

Jersey, Guice and Hibernate - EntityManager thread safety

烂漫一生 提交于 2019-12-19 12:20:06
问题 I have used this tutorial them same way in my application: http://www.benmccann.com/hibernate-with-jpa-annotations-and-guice/ My app is JAX-RS web service which will receive many concurrent requests and make updates to database. GenericDAOImpl.java implementation: public class GenericDAOImpl<T> implements GenericDAO<T> { @Inject protected EntityManager entityManager; private Class<T> type; public GenericDAOImpl(){} public GenericDAOImpl(Class<T> type) { this.type = type; } @Override public

Apache Transaction:write file transactionally - how to use resourceId

梦想的初衷 提交于 2019-12-19 06:18:12
问题 If anybody implemented transactional writing to file,please, assist me. Related topic was discussed in earlier thread(transactional write). Use case is following: if writing to log file is failed,that appropriate DB transaction shoud be rolled back. So the writinig to file should be performed in transactional way. I've chosen Apache Commons Transaction lib. And have issue,that doesn't let me go further,because haven't found appropriate documentation or examples. I have created instance of