Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6649577
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:47:26+00:00 2026-05-26T00:47:26+00:00

How can an encapsulate non-database actions into transactions? For example, say I have some

  • 0

How can an encapsulate non-database actions into transactions?

For example, say I have some number of methods/functions called in sequence, some update the database, some update files on the filesystem, some update parameters in the HttpSession, some update the cache, etc. If one of the latter ones fails, like updating the session, how can I roll back all the other changes on the file system, in the DB, etc.?

The environment is a Java Servlet container like Tomcat with something like Struts2, any RDBMS, a persistence layer like Hibernate or Ibatis, etc.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T00:47:27+00:00Added an answer on May 26, 2026 at 12:47 am

    All these would have to be transactional resources, able to participate in a 2-phase commit protocol, in order to do what you want.

    Unless you have a bug in your code, the update to the session should never fail. You could thus do it after the other updates are successful. The file system should just be avoided if you need something transactional. The alternative could be to start by saving to the file system, then do the database updates, and accept to have useless files in the file system if the DB update fails.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm curious as to how many of these queue methods I can encapsulate into
Simplified example: I have a to-do. It can be future, current, or late based
Here is an overly simplistic example for illustration: I can encapsulate an implementation detail
Auto generating entities from a legacy database. Many of the tables have non standard
If I have an inline stylesheet, can and I want - for some strange
Summary Can you explain the reasoning behind the syntax for encapsulated anonymous functions in
can you recommend some good ASP.NET tutorials or a good book? Should I jump
Can I do WHERE operations on a calculated date field? I have a lookup
I'm working on application which can be logically grouped into a core engine, and
I have an object can be compose by components but each components has a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.