Announcement Announcement Module
Collapse
No announcement yet.
Need advice regarding JTA Hib and Transactional File Access Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Need advice regarding JTA Hib and Transactional File Access

    Hey everybody, my current situation is this: I'm using hibernate with springs HibernateTransactionManager on my proxied business service classes with TransactionProxyFactoryBean. I've now run into a situation where I am doing some file read/write/create/deletes in the same method as hibernate acesses, and what gets written into my db depends on the file operations. For example if a user wishes to replace a file in my app my method will load the row from hibernate to get the file name, delete the file, create a new file, save it, then save its name into my db on that row. Currently if an exception is thrown from the file accesses it will roll back the database transaction, however the files will be in a semi unknown state (did the delete fail? did the new write fail?). And similarly if it fails writing to the database the files are all in their new condition but the database is rolled back. So major problems.

    To attempt to solve this I just noticed the Commons Transaction project, and specifically within that, Transactional File Access http://jakarta.apache.org/commons/tr...ile/index.html. I would like to integrate this into my methods where I have a single transaction working with hibernate and the File Resource Manager. However I can only see a couple ways of doing this:

    1-Extending the HibernateTransactionManager and shoehorning in the code to work with the Transactional File Package. This would be VERY ugly and may not even work since the transaction object passed around is specific to hibernate, and not meant to hold information for this new stuff.

    2-Migrating my setup to JTA and using a HibernateTransactionManager in conjunction with a new TransactionManager for this file tranasactional behavior.

    I have MANY questions on #2.. beginning with is there anything in spring that already does this? Darn didn't think so. So secondly I use Tomcat as my webserver, and I've read there is JOTM that can implement JTA.. has anyone sucessfully used that with spring and Tomcat 5.x? Also would I need to do any configuration changes to my current setup with hibernate to make it work under JTA? I'm using declarative transaction management right now pointing at specific methods to wrap transactions around, would that still work the same with JTA or do I have to move all that stuff into a JTA config somehow? Is it going to be really difficult and not worth the effort to write a transaction manager for commons transaction?

    I appreciate any help and advice given as this is new territory for this developer.

    thanks!

  • #2
    I am also facing this same issue as well for the project we are working on. So any solutions in this area would be of use to me as well. Mabye we can come up with a solution w/ the spring developers for this to contribute back to the community.

    Comment


    • #3
      Spring Transactional File Access

      Same problem here...any hints in this direction

      Thanks,
      Franklin

      Comment


      • #4
        I can provide the hints:
        http://forum.springframework.org/sho...t=32704&page=2
        http://forum.springframework.org/showthread.php?t=37359
        But haven't made much progress since making that public

        Joerg

        Comment


        • #5
          Hi,

          Commons Transaction does not support XA transactions, afaik. You can use XADisk to perform the file operations inside the XA transaction. This same XA transaction can include other XA-enabled resources like database also.

          Hope that helps.

          Thanks,
          Nitin
          Last edited by nitin_verma; Feb 12th, 2012, 03:38 AM.

          Comment


          • #6
            thanks for the post...

            Comment

            Working...
            X