We use hibernate as our JPA implementation provider. I am reading a resultset list using the query below from the database. I would like to cache this data and keep it in session scope, so I dont need to make a call to the database every time I need this data. Please suggest nice way to do this.
The second level cache will not cache this unless you have configured the query cache, and then it will cache the IDs only.
"Session scope" could mean a bunch of things here. If it s the Hibernate Session, you are already caching there (assuming you load the objects you return from this query into the Hibernate session). If its the EJB session, you can cache the detached objects there easy enough and the same goes for the HTTPSession.