Announcement Announcement Module
Collapse
No announcement yet.
Commons Transaction Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Commons Transaction

    Has anyone used the newly promoted Commons Transaction for dealing with file writing/reading in a transaction setting? I have a few service methods that write or delete a file then stick the file name into a database. I have rollback working great for database exceptions where it can't write the filename, but I have no ability to delete the file if there is a failure writing its name to the database. Is there a built in spring mechanism for this or should I pursue creating a type of transaction aspect thing with this commons Transaction?

  • #2
    For this specific usecase, you can create a org.springframework.aop.ThrowsAdvice and hook it as a preInterceptor into your TransactionProxyFactoryBean. The advice should be responsable for files deletion if a DataAccessException / MyApplicationException is thrown.
    HTH

    Comment

    Working...
    X