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 8817731
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:55:19+00:00 2026-06-14T04:55:19+00:00

Suppose I have a session bean that implements a REQUIRED transaction method: @TransactionAttribute(TransactionAttributeType.REQUIRED) public

  • 0

Suppose I have a session bean that implements a REQUIRED transaction method:

@TransactionAttribute(TransactionAttributeType.REQUIRED)
public void doTransaction() throws Exception {
    try {
        ...
        // call to non-EJB bean object (not session, stateless or entity bean)
    } catch (Exception e) {
        context.setRollbackOnly();
        throw e;
    }
}

Suppose doTransaction() changes the internal state of the non-bean object, and fails. Does the rollback restore the original state of the non-bean?
If not, what would be the recommanded way to handle such a case? (or are POJO calls within a transaction not allowed?)

  • 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-06-14T04:55:20+00:00Added an answer on June 14, 2026 at 4:55 am

    The rollback that EJB automatically does after e.g. an exception is thrown, will only affect resources that have joined the ongoing (JTA) transaction.

    There are a couple of ways to join such a transaction. The most complete way is by implementing the XAResource interface and letting your code enlist that implementation. A simpler, but less powerful way is to use a Synchronizer.

    Strictly speaking, neither the EJB container or transaction manager itself rollbacks anything. Instead, it gives the enlisted resources an opportunity to do such rollback. Thus, it will never by itself be able to restore previous values of random variables that happen to have been modified during a transaction.

    For completeness, the resources that are typically (automatically) enlisted in a transaction are database connections (if they come from a container managed datasource), JMS messages (again, if the destination is container managed), (distributed) caches, and JCA based EIS resources.

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

Sidebar

Related Questions

Suppose I have a pure virtual method in the base interface that returns to
Suppose I have a static method of my class that returns an object of
Suppose I have a method session.get(str: String): String but you don't know whether it
Suppose I have a WCF service that is not session or singleton based and
Suppose I have a class Baz that inherits from classes Foo and Bar ,
Suppose I have a simple model, such as Record: @Model public class Record {
Suppose I have a process that is updating a record and encounters a record
Suppose that I have the following mapping with a formula property: <class name=Planet table=planets>
Suppose I have a view that rolls up data via a GROUP BY clause:
Suppose we have a service with the following methods. [ServiceContract(SessionMode = SessionMode.Required, CallbackContract =

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.