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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:57:10+00:00 2026-05-26T02:57:10+00:00

After I commit some data into the database I want my session beans to

  • 0

After I commit some data into the database I want my session beans to automatically refresh themselves to reflect the recently committed data. How do I achieve this when using managed session beans in JSF 2.0?

Currently I have to restart the web server in order for the sessions to clear and load anew again.

  • 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-26T02:57:10+00:00Added an answer on May 26, 2026 at 2:57 am

    2 ways:

    1. Put them in the view scope instead. Storing view-specific data sessionwide is a waste. If you have a performance concern, you should concentrate on implementing connection pooling, DB-level pagination and/or caching in the persistence layer (JPA2 for example supports second level caching).

      @ManagedBean
      @ViewScoped
      public class FooBean {
          // ...
      }
      

    2. Add a public load() method so that it can be invoked from the action method (if necessary, from another bean).

      @ManagedBean
      @SessionScoped
      public class FooBean {
      
          private List<Foo> foos;
      
          @EJB
          private FooService fooService;
      
          @PostConstruct
          public void load() {
              foos = fooService.list();
          }
      
          // ...
      }
      

      which can be invoked in action method inside the same bean (if you submit the form to the very same managed bean of course):

          public void submit() {
              fooService.save(foos);
              load();
          }
      

      or from an action method in another bean (for the case that your managed bean design is a bit off from usual):

          @ManagedProperty("#{fooBean}")
          private FooBean fooBean;
      
          public void submit() {
              fooService.save(foos);
              fooBean.load();
          }
      

      This of course only affects the current session. If you’d like to affect other sessions as well, you should really consider putting them in the view scope instead, as suggested in the 1st way.

    See also:

    • How to choose the right bean scope?
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a tool which will push changes to database after commit to svn.
I commit some data in DB with nhibernate. TimeSlices newTimeSlices = new TimeSlices(timeSliceStartTime, timeSliceEndTime,
Is there any way to run some code after transaction commit in Django? I
I have a table A into which I am inserting data. Then some calculation
I have some commits that I've decided, after the fact, are going to be
I know that it's possible to get SVN to send emails after a commit
Sqlldr is corrupting my primary key index after the first commit in my ctl
How often should I commit changes to source control ? After every small feature,
I have a working folder. I use Commit by right-clicking on it after my
I have a list of 10 data objects that I want to insert/update 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.