• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Hibernate and IO transactions

 
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am building a process to upload a file to a file server and catalog the file attributes in SQL Server. I am using Hibernate to access the databases. I wonder if there is a way to include the IO call in the transaction, so if either the IO or the database call dies, they both get rolled back. Any ideas?
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
File systems are not transactional, so you won't get the rollback behaviour you want from a transaction. There are I believe transactional file system implementations out there, though I've never used one.
 
Sheriff
Posts: 3837
66
Netbeans IDE Oracle Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You might put the files into the database instead of separate file server then.

Though this solution is not favoured by everyone as it has pros and cons of its own, that way you get the transactional integrity plus auditing and security capabilities if need be, and ease of administration - one backup for all, ability to do point in time recovery if required, no need to maintain a file server, reduction of possible point of failures, and so on.

On the other hand, in the database the files might take slightly more space than in a file server and also volumes of undo/redo logs or other administrative areas would be increased.
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

If you wish to combine more than one resources inside a single transaction, you will have to use XA/JTA transactions. Though databases support both normal and XA transactions, but since filesystems do not support transactions (none of normal and XA transactions), you can rely on XADisk which exposes APIs for file/directory operations to enable transactions (both normal and XA) over filesystems.

Hope that helps.

Thanks,
Nitin
 
Make yourself as serene as a flower, as a tree. And on wednesdays, as serene as this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic