spring-transactions

@ManagedBean and @Transactional - bug in Spring? Workarounds?

两盒软妹~` 提交于 2019-12-12 03:08:23
问题 I had the following JSF backing bean in my Webapp @ManagedBean class MyBackingBean implements Serializable { private MyHibernateRepository repository; ... @Transactional public void save() { .... repository.save(myObject); } } When it gets to the repository.save method call - I get the following error no transaction is in progress I've got two questions Is this because of a bug like this? I believe there are two workarounds - are there any others? 2.1 First workaround - using

flush session in the middle of transaction

﹥>﹥吖頭↗ 提交于 2019-12-12 02:25:24
问题 Stack : spring and hibernate. service method looks like below, @Transaction (readonly=false) public void doSomething(){ step1: fetch object1, step2: modify list from object1 (i.e object1.getListObject2()), step3: fetch object3, step4: do some more processing, } I noticed that session is flushed in step3. Not able to understand why session has to be flushed in the middle of transaction. 回答1: It most certainly needs to be flushed in order for the query executed at step 3 to retrieve the correct

Spring @Transactional propagation is not working

时光怂恿深爱的人放手 提交于 2019-12-12 02:24:38
问题 I have a very simple code comprising of Service -> RequestProcessor -> DAO having 2-3 classes (interface, abstract, concrete) in each layer. Service layer:- public interface Service { public void saveOrUpdate(Object entity, String operationName); } } public abstract class AbstractService implements Service{ public abstract ReqProcessor getRP(); @Override public void saveOrUpdate(Object entity, String operationName) { ReqProcessor hiberTestRP = getRP(); hiberTestRP.saveOrUpdate(entity,

How to support Transactions in Neo4j Rest

Deadly 提交于 2019-12-12 01:56:29
问题 We build a Grails Application using the database Neo4j ,And We used Spring Data Neo4j rest , As per the requirement of any Application , it should provide the facility of Transaction . But using Neo4j When we save a Node and Exception occur in executing the code then the node is save but its relationship is not save How to resolve this problem ??? Can we use Spring Transaction Management or any other thing ??? 回答1: In the past it was a shortcoming of the Neo4j-REST APIs to not expose

Spring Hibernate C3P0: Connections not released

断了今生、忘了曾经 提交于 2019-12-12 01:45:48
问题 C3P0 is not releasing connections after a transaction completes. Here's the stack trace: java.lang.Exception: DEBUG STACK TRACE: Overdue resource check-out stack trace. at com.mchange.v2.resourcepool.BasicResourcePool.checkoutResource(BasicResourcePool.java:555) at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutAndMarkConnectionInUse(C3P0PooledConnectionPool.java:755) at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:682) at

Normal Spring + Hibernate Transaction behaviour?

故事扮演 提交于 2019-12-12 01:44:16
问题 I've got my Spring + Hibernate project configured to be transactional using Spring AOP. When I check in the DAO method with TransactionSynchronizationManager.isActualTransactionActive() it says true. I'm calling two DAO methods from my service class and in the second DAO method, I do 'devide by zero' intentionally to throw an error and see if the two method rollback. Currently the first one seems to insert a new record just fine. Shouldn't the first method rollback ? Update You can refer to

Is Spring @Service transactional?

别等时光非礼了梦想. 提交于 2019-12-11 23:19:37
问题 When I am on a spring service and I want to update several database tables through spring repositories, do I need to add @Transactional to make sure I am transactional and rollback or is it already there? If yes, do I need to add it to the class level or method? 回答1: The answer is Yes, you need to add it separately. For more details, please refer: What is the difference between defining @Transactional on class vs method and Spring - @Transactional - What happens in background? and https:/

Spring @Transactional annotation does not roll back

拜拜、爱过 提交于 2019-12-11 20:27:52
问题 My @Transactional annotation doesn't rollback the first insert when the second update sentence fails (with a non- RuntimeException ). The exception is launched in updateNumeroVotos but Spring doesn't rollback the insert of save operation. Any idea? I have these files: IdeaService.java code: @Service public class IdeasServiceImpl implements IdeasService { @Autowired all daos code /** * Metodo que inserta un voto de un usuario */ @Override @Transactional(propagation = Propagation.REQUIRED)

spring @Transactional JDBC Template MySQL DB not rolling back

孤街醉人 提交于 2019-12-11 17:52:52
问题 I am trying to implement the Spring @transactional with jdbc templates from the service layer calling 2 insert methods in a DAOImpl and using simplejdbctemplate to the insert and i see in the logs that spring creates a new transaction on my service method and my first insert suceeds and the second insert fails and even though it says it is rolling back on the same connection the first insert never get rolled back from my Mysql DB.(i am using innodb engine). Here is my service method. @Service

SimpleJDBCCall Spring not execute

帅比萌擦擦* 提交于 2019-12-11 17:46:19
问题 I have this method public void importarAdiantamento(ArrayList<LayoutArquivo> arquivos, Usuario usuario) throws Exception { try { for(LayoutArquivo arquivo : arquivos) { DateFormat fmt = new SimpleDateFormat("dd/MM/yyyy"); SqlParameterSource in = new MapSqlParameterSource() .addValue("DATAVCM", new java.sql.Date(fmt.parse(arquivo.getVencimento()).getTime())) .addValue("VALOR", arquivo.getValor()) .addValue("MOTIVO", arquivo.getCodMotivo()) .addValue("EMPRESA", arquivo.getCodEmpresa())