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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:38:03+00:00 2026-05-27T14:38:03+00:00

In my application, I have an @ApplicationScoped CDI bean to store some information from

  • 0

In my application, I have an @ApplicationScoped CDI bean to store some information from the database:

@Named
@ApplicationScoped
public class MrBean {
   @EJB
   private SoyaBean soyaBean;
   private List<Toys> myToys;

   @PostConstruct
   public void prepareMrBean() {
      this.myToys = soyaBean.getToys();
   }

   public void updateToys() {
      this.myToys = soyaBean.getToys();
   }
}

I also have a AddToy.xhtml page which would simply add a toy to the database. The backing bean is as following:

@Named
@RequestScoped
public class MrsBean {
   @EJB
   private SoyaBean soyaBean;
   @Inject
   private MrBean mrBean;

   public void addToy() {
      this.soyaBean.addToy();
      this.mrBean.updateToys();
   }
}

Since there is a new toy added to the database, I wanted to update the list of toys in mrBean. However, even though mrsBean called mrBean.updateToys(), the list of toys in mrBean is not updated at all. I have another ViewToys.xhtml with a @RequestScoped backing bean to view the list of toys and I didn’t see the list get updated.

I’d be very grateful if someone could give me an advice on how to tackle this problem.

UPDATE: This is my SoyaBean implementation:

@Stateless
public class SoyaBeanImpl implements SoyaBean {
   @PersistenceContext()
   private EntityManager em;

   @Override
   public List<Toys> getToys() {
      Query q = em.createQuery("SELECT T from Toys T");
      return (List<Toys>) q.getResultList();
   }

   @Override
   public void addToy() {
      Toys newToy = new Toys();
      em.persist(newToy);
   }
}

UPDATE 2 I’d also really appreciate if someone could show me how I can achieve the same goal in any ways other than my troubling way.

Best regards,

James Tran

  • 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-27T14:38:04+00:00Added an answer on May 27, 2026 at 2:38 pm

    The problem was that the results of all SQL queries were cached. Hence, even though I tried to refresh the list of toys, it only received the old result. I solved this problem by setting the option Shared Cache Mode in the file persistence.xml to None.

    I believe not using cache at all is not a good option. Hence, I’d be very grateful if someone could show me how I can achieve the same result without having to turn off cache.

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

Sidebar

Related Questions

My application have to load some points from internal sqlite database of android, and
I see an application have used Log.info = some info where are these logs
In my console application have an abstract Factory class Listener which contains code for
My Application has 3 activities (MainActivity,SampleActivity,TempActivity) and Application have to start from MainActivity because
I have application with needs to have access to some sensitive data(in this case
I have a dataTable which has a value of a bean class which looks
I have information stored in a database (actually a content repository but this shouldn't
My application have some problem on opening 32bit BMP images. some image has alpha
my application have grid view contain lot's of images and as from the Android
I have an simple (webprofile) EJB 3.1 Application and try do determine the current

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.