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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T00:15:51+00:00 2026-06-14T00:15:51+00:00

I switched my application’s entity manager factory from spring-managed to container-managed and have run

  • 0

I switched my application’s entity manager factory from spring-managed to container-managed and have run into a problem. While creating an entity, there are times when I have to query for it within the same transaction that it was originally created in, before it has been flushed automatically at the end. In spring, the entity manager would (I believe) automatically flush the context before running find and be able to return the correct object, but in jboss the find method returns null.

Here is a sample of the problem:

@PersistenceContext
private EntityManager entityManager;

private void test(){
    Person person = new Person("firstname", "lastname", "email", "user", "pass", Person.PersonType.admin);
    entityManager.persist(person);
    assert person.getId() != null;
    Person person2 = entityManager.find(Person.class, person.getId());
    assert person2 != null; //fail in jboss, ok in Spring
}

If I try to add an entityManager.flush() call in between persist() and find() methods, jboss throws a javax.persistence.TransactionRequiredException: no transaction is in progress error, regardless of whether I throw @Transactional annotations around the method/class running the test.

My persistence.xml file sets <property name="org.hibernate.FlushMode" value="auto"/>, but it doesn’t seem to be working.

Is there some configuration property that I missed to tell jboss to flush its context to the database before running a Find? Or am I ordering my statements incorrectly?

I’ve put my persistence.xml and my-ds.xml files on pastebin.

Thanks for the help.

Edit

Resolved. See comments below

  • 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-14T00:15:53+00:00Added an answer on June 14, 2026 at 12:15 am

    Soon after uploading my spring-data.xml, I realized that I forgot the bean. After adding that, the @Transactional tag worked as expected and the problem was resolved.

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

Sidebar

Related Questions

I have just switched from VB.Net to C# and am writing a windows application.
We have a C# application written in C# and recently switched over from MbUnit
Application.Run(new Main()); This line gives TypeInitializationException was unhandled after I switched from 3.5 to
I have a application where I switched out the communication from TCPClient to using
I have a multipage application which needs to manually switched from one page to
I switched my DAL from using LINQ over to Entity Framework. Because my application
So I have a language setting in my application. When the language is switched,
I recently switched from restful_authentication to authlogic for authenticating users for my application. I've
We just recently switched from Visual Studio 2008 to Visual Studio 2010. I have
I have a Node.js application on Heroku. I've recently switched a long query to

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.