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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T06:29:33+00:00 2026-05-18T06:29:33+00:00

Consider this simplified view of some code with which I’m working: @Stateless(…) @Remote(…) @TransactionAttribute(TransactionAttributeType.MANDATORY)

  • 0

Consider this simplified view of some code with which I’m working:

@Stateless(...)
@Remote(...)
@TransactionAttribute(TransactionAttributeType.MANDATORY)
public class FirstEjbType {

   @EJB(...)
   private SecondEjbType secondEjb;
   @EJB(...)
   private ThirdEjbType thirdEjb;

   public void doSomething() {
      secondEjb.doSomething();  // WRITES SOMETHING TO THE DATABASE
      thirdEjb.doSomething();  // CAN'T SEE THAT SOMETHING IN THE DATABASE!
}

I’ve set the TransactionAttribute annotation to MANDATORY at the class-level. I understand this to mean that all methods such as doSomething() must be invoked within a supplied transaction. We are using container-managed transactions in this case.

The TransactionAttribute is not used at all in SecondEjbType or ThirdEjbType… neither at the class nor method level. I understand this to mean that secondEjb.doSomething() and thirdEjb.doSomething() will both operate within the transaction supplied for firstEjb.doSomething().

However, I’m seriously missing out on something! As indicated by the code comments… secondEjb writes data to a database, and thirdEjb reads that data as part of its operation. Since all of this is running within the same transaction, I would not expect there to be any issues with isolation levels. However, for whatever reason the secondEjb database write isn’t visible to thirdEjb.

I’ve turned tracing all the way up to the max, and there’s apparently not an exception or error or rollback at issue… the initial write simply isn’t visible to the subsequent read. I don’t claim to be the world’s greatest guru in transaction management… have I missed something obvious, or is my conceptual understanding basically correct and the issue may lie elsewhere?


UPDATE – Additional information requested by johnstok below:

  • I am running in GlassFish
  • I’m not sure what you mean by “non-standard flush mode”, so I assume the answer is no.
  • My persistence.xml file looks like this:

<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
    <persistence-unit name="pu" transaction-type="JTA">
       <jta-data-source>jdbc/datasource</jta-data-source>
        <exclude-unlisted-classes>false</exclude-unlisted-classes>
        <properties>
            <property name="toplink.cache.shared.default" value="false"/>
        </properties>
    </persistence-unit>
</persistence>

  • 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-18T06:29:34+00:00Added an answer on May 18, 2026 at 6:29 am

    I’ve learned a ton from all the answers here, and can’t thank people enough. However, I believe that my question has muddied the waters to a point where it might be better to start over with a different question.

    It doesn’t appear that jumping from one EJB to the next and back has anything to do with anything. To simplify matters, I tried working with a test case completely isolated to one EJB. I went into that secondEjb.doSomething() method, which persists an entity to the database. At the end of the method, I added an em.flush(), and tried retrieving the entity again with a JPA query.

    Even though I was still in the exact same method where the entity had just been persisted, it was not visible to that subsequent query. I’ve done some additional research elsewhere, and it looks like this may simply be the normal mode of isolation for JPA in a transactional context. One a transaction is started, additional queries within that transaction don’t yet have visibility to uncommitted data.

    If my summary of the linked CodeRanch discussion is accurate, then “yuck” on JPA! 🙂 Either way, I’ve refactored the code to avoid this issue altogether.

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

Sidebar

Related Questions

Consider the code below (which has been simplified). I have a service class that
Consider this typical code for method tracing (simplified for illustration): type IMethodTracer = interface
Consider this code: enum { ERR_START, ERR_CANNOTOPENFILE, ERR_CANNOTCONNECT, ERR_CANNOTCONNECTWITH, ERR_CANNOTGETHOSTNAME, ERR_CANNOTSEND, }; char* ERR_MESSAGE[]
Consider this (rather pointless) javascript code: function make_closure() { var x = 123, y
Consider this code in a php file on my VPS server: <?php $url =
Consider the following (simplified) code: enum eTestMode { TM_BASIC = 1, // 1 <<
Consider the overly simplified example below; some of it written with pseudocode for brevity.
Consider this model (simplified for this question): class SecretAgentName(models.Model): name = models.CharField(max_length=100) aliases =
Consider the following Python script, which uses SQLAlchemy and the Python multiprocessing module. This
Consider the following simplified version of my code. I have a template class 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.