File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Spring and the fly likes Problem with commit in a method marked with @Transactional Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Problem with commit in a method marked with @Transactional " Watch "Problem with commit in a method marked with @Transactional " New topic
Author

Problem with commit in a method marked with @Transactional

Alexey Saenko
Ranch Hand

Joined: Aug 18, 2008
Posts: 30

Hi all,

The problem is in the following. There is Websphere 8.5 application server where is set up XA datasource. And there is an application which is written on Spring 3.2.2 with Hibernate 4.1.7. I have a DAO class which has one persist() method marked with @Transactional annotation and should just persist an object to the database. As a result it returns persisted object with id (hibernate performs request for the new one), but actually the object is not written to the database and there are no stacktraces in the logs. TransactionSynchronizationManager.isActualTransactionActive() returns true in the method persist().

All persistence objects are configured with annotations.

Spring configuration is in xml-form and looks like this:

Do you have any ideas how could I make DAO save an object to the database?

Thanks in advance.


SCJP 6, SCBCD 5, OCEWSD 6
My blog: http://darkleden.wordpress.com
Kathleen Angeles
Ranch Hand

Joined: Aug 06, 2012
Posts: 123

And there are no other transactions in that unit flow? In other words, are there other resources involved, that could have caused a rollback, which cascaded to your persist? E.g. you can have 2 datasources, this one succeeded and the other one failed, and since you are using XA, I guess you are capable of multi-resource rollback.

- k


----------------------------------------------------------------------------------------
[SpringSource Certified Spring Professional (Spring Certification) - Practice Tests]
Alexey Saenko
Ranch Hand

Joined: Aug 18, 2008
Posts: 30

@Kathleen for the moment there is only one datasource.

I've also forgotten to mention that persisting runs as follows
Alexey Saenko
Ranch Hand

Joined: Aug 18, 2008
Posts: 30

Finally, it started to work with the following configuration.

persistence.xml

web.xml

spring-beans.xml
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem with commit in a method marked with @Transactional