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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:11:32+00:00 2026-06-14T22:11:32+00:00

I have a method to save a new object in an EJB bean. This

  • 0

I have a method to save a new object in an EJB bean. This method is called, without error, but nothing changes in the database. I can’t understand why.

Here is the code:

@Stateless(name = "Ar", mappedName = "ManagementBean")
public class ManagementBean implements IManagementBeanLocal, IManagementBeanRemote {
...
    @Override
    public int storeRawSms(String raw, String requestUid, String text, String service, boolean correctlyAnalysed, Date receivedTimestamp,
            boolean toBeAnalysed, String phoneNumber) {

        // Get phone number, create if it dosn't exist
        PhoneNumber pn = getOrCreatePhoneNumberPrivate(phoneNumber);

        // Create rawSMS
        RawSms rawSms = new RawSms(raw, requestUid, text, service, correctlyAnalysed, receivedTimestamp, toBeAnalysed, pn);

        // Store and return result
        em.persist(rawSms);
        int result =  rawSms.getId();

        em.flush();
        em.clear();

        return result;
    }

...

And the caller:

@PersistenceContext private EntityManager em; 
... 
int rawSmsIs = bean.storeRawSms(raw, requestUid, message, service, false, new Date(), true, sender);

Do you have an idea?

  • 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-14T22:11:33+00:00Added an answer on June 14, 2026 at 10:11 pm

    It seems that your transaction never commited, so try changing transaction management:

    @Stateless(name = "Ar", mappedName = "ManagementBean")
    @TransactionManagement(TransactionManagementType.BEAN)
    public class ManagementBean implements IManagementBeanLocal, IManagementBeanRemote {
    
          @Resource
          private UserTransaction utx;
    
          @Override
          public int storeRawSms(..) {
    
                try {
                      utx.begin();
                      ..
                      em.persist(rawSms);
                      int result =  rawSms.getId();
                      utx.commit();
                }
                catch(Exception ex) {
                      //EXCEPTION HANDLING
                      utx.rollback();
                }
          }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following method to save an Object to a file: // Save
I have problem with ObjectContext.SaveChanges method: public void Save(Action<object, object> action) { EventAggregator.GetEvent<EntityServiceRequestingEvent>().Publish(true); var
Suppose you have a method: public void Save(Entity data) { this.repositoryIocInstance.EntitySave(data); } Would you
I asked a question about this method: // Save an object out to the
We have repositories which have a Save method. They also throw a Created event
I have an ActiveRecord before_save method throwing an odd error: class MyThing < ActiveRecord::Base
I have the following method that is supposed to be a generic Save to
I have a small issue with a method that should save the text contained
I have method that returns Drawable , and if its Bitmap object is recycled
I have written this code which accesses the Delete method on Web Service x,

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.