If the data you are loading isn't changing, you could load it on start up and detach your hibernate objects or cache the data in any number of other ways so that it is still available after the loading session has closed. WorkManager would be the appropriate way to load data outside of Request/Response cycle in a web application.
http://www.wideplay.com/transactionsemantics, see the section on "Custom Units of Work." You could also rely on the various caching mechanisms hibernate provides, rather than doing this yourself. Ed. On Tue, May 11, 2010 at 11:56 AM, Christoph Grün <[email protected]> wrote: > Thanks! In this class, some data is saved into hibernate objects and then > the session is closed. However, in my case I would like to load some > instances from Hibernate, Jena, etc. as well as images from different > sources and hold them in memory so that I save time as soon as an HTTP > request needs them. > > > > I think that WorkManager.beginWork is not appropriate as I cannot access > this data from an HTTP session. > > > > Christoph > > > > *Von:* [email protected] [mailto:[email protected]] > *Im Auftrag von *Edward Zarecor > *Gesendet:* Dienstag, 11. Mai 2010 17:50 > > *An:* [email protected] > *Betreff:* Re: warp persist, guice & wicket: use warp persist not in http > request > > > > Sorry, I had meant to paste this URL into the original email -- > multi-tasking! > > > > http://jweekend.co.uk/dev/LegUp > > Use the form to generate a maven command and run it locally. The code will > be under src/java as per usual. > > > > Ed. > > > > On Tue, May 11, 2010 at 11:36 AM, Christoph Grün <[email protected]> wrote: > > Ed, thanks a lot for your answer. Where can I find the DataInitializer.java > class? > > > > Thanks, Christoph > > > > *Von:* [email protected] [mailto:[email protected]] > *Im Auftrag von *Edward Zarecor > *Gesendet:* Dienstag, 11. Mai 2010 16:50 > > > *An:* [email protected] > *Betreff:* Re: warp persist, guice & wicket: use warp persist not in http > request > > > > Take a look at one of the Guice, Warp and Wicket Archetypes available here, > especially useful as you are using Wicket. > > > > Isn't what you are trying to accomplish analogous to what happens in > DataInitializer.java? > > > > Ed. > > On Tue, May 11, 2010 at 9:40 AM, Christoph Grün <[email protected]> wrote: > > Thanks for the link! > > > > But I think it cannot be used in a web application because when endWork() > is called, all sessions are closed. I would like to keep all the objects, > loaded from the database, in memory for incoming http requests. > > > > Christoph > > > > *Von:* [email protected] [mailto:[email protected]] > *Im Auftrag von *Edward Zarecor > *Gesendet:* Dienstag, 11. Mai 2010 15:29 > *An:* [email protected] > *Betreff:* Re: warp persist, guice & wicket: use warp persist not in http > request > > > > See: > > > > http://code.google.com/p/warp-persist/wiki/WorkManager > > > > Ed. > > On Tue, May 11, 2010 at 4:24 AM, Christoph Grün <[email protected]> wrote: > > Hi all, > > > > I am using Wicket together with Guice and Warp Persist/Servlet. > > I have registered the PersistenceService in the contextInitialized method. > However, I would like to do some data loading from the database when wicket > starts, and like to access Hibernate Daos. I am getting the error: > > > > org.hibernate.HibernateException: No session currently bound to execution > context > > at > org.hibernate.context.ManagedSessionContext.currentSession(ManagedSessionContext.java:50) > > at > org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:591) > > at > com.wideplay.warp.hibernate.SessionProvider.get(SessionProvider.java:42) > > at > com.wideplay.warp.hibernate.SessionProvider.get(SessionProvider.java:32) > > > > Using Hibernate from an HTTP request is no problem. How can I configure > Warp to use it directly from WicketApplication? > > > > Thanks a lot, Christoph > > > > public class Init extends WarpServletContextListener { > > > > @Override > > public void contextInitialized(ServletContextEvent event) { > > super.contextInitialized(event); > > INJ.getInstance(PersistenceService.class).start(); > > event.getServletContext().setAttribute("injector", INJ); > > } > > > > @Override > > public void contextDestroyed(ServletContextEvent event) { > > super.contextDestroyed(event); > > > > } > > > > -- > You received this message because you are subscribed to the Google Groups > "google-guice" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<google-guice%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/google-guice?hl=en. > > > > -- > You received this message because you are subscribed to the Google Groups > "google-guice" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<google-guice%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/google-guice?hl=en. > > -- > You received this message because you are subscribed to the Google Groups > "google-guice" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<google-guice%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/google-guice?hl=en. > > > > -- > You received this message because you are subscribed to the Google Groups > "google-guice" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<google-guice%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/google-guice?hl=en. > > -- > You received this message because you are subscribed to the Google Groups > "google-guice" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<google-guice%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/google-guice?hl=en. > > > > -- > You received this message because you are subscribed to the Google Groups > "google-guice" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<google-guice%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/google-guice?hl=en. > > -- > You received this message because you are subscribed to the Google Groups > "google-guice" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<google-guice%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/google-guice?hl=en. > -- You received this message because you are subscribed to the Google Groups "google-guice" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-guice?hl=en.
