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

  • Home
  • SEARCH
  • 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 9274301
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T16:19:21+00:00 2026-06-18T16:19:21+00:00

In a Web App, need to display a view of 6 objects (rows of

  • 0

In a Web App, need to display a view of 6 objects (rows of table DB) via JSF per page. To advance to the next view another different random 6 objects are to be displayed and so on…

So I was thinking in having a @Singleton that queries all the rows of the table with a @Schedule job in a given interval, let’s say every 1 hour. It will have a getCollection() method.

Then every visitor will have a @SessionScoped CDI bean, that will query the Collection of the @Singleton, then shuffle it to make a random view to the specific user.

As with many visits, many CDI beans will be created that will access the getCollection() method concurrently.

Is this thought correctly? Any specific annotations are needed for this case? Any other way of doing this?

—–UPDATE—

After speaking with friends, specially Luiggi Mendoza, they tell me that best thing here is to use a EHCACHE or similar, instead of a Singleon. I think that’s the way.

  • 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-18T16:19:22+00:00Added an answer on June 18, 2026 at 4:19 pm

    Will you have a cluster of webservers? In that case you need a distributed cache or you need to update state through the database.

    Else I would just go for a simple map in a bean that is @ApplicationScoped.

    I use JPA in a solution where a big bunch of data is almost always the same. There’s more then one tomcat involved so a pure cache in a bean that is @ApplicationScoped won’t work. To fix it I have no second level cache and instead cache the result of the database queries. That means each tomcat has it’s own cache.

    For every login a timestamp is read, if the data in the cache is not stale it is used. Otherwise the cache is updated. The timestamp is updated when changes occur with the help of database triggers.

    @PrePersist
    @PreUpdate
    @PreRemove
    public void newTimeStamp() {
    // save a new timestamp
    }
    

    @Singleton is not part of the CDI specification so I would refrain from using it.

    Also I would keep my client bean @RequestScoped and reload the 6 objects with @PostConstruct. That way you will get a fresh 6 for every request.

    Or if that is to short lived maybe @ViewScoped (requires myfaces codi), @ConversationScoped or @ViewAccessScoped (requires myfaces codi).

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

Sidebar

Related Questions

I have an app with web view, where I display a feedback HTML page,
My web app requires users to cast votes via twitter and display those votes
I'm working on a web app where I need to display a service mark
I am making a web app, using ASP.NET. Basically, I need to display data
I'm making a web app which display a HTML table. The app is written
When my website/web app displays a picture, I need to allow the users to
I'm am building a web app and need a text to speech which highlights
When we are building html5 web app or ios hybrid app,we need to make
I'm developping a web app and I need encrypt strings in javascript to compare
We are creating a web app where we need to have concurrency for 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.