Re: Using Wicket and Hibernate
Here's an example of wicket spring and hibernate all working together, with an h2 database: https://github.com/dalvizu/wicket-spring-hibernate-template -Dan On Thu, Nov 21, 2013 at 8:30 AM, Gerrit Wassink wrote: > Hello, > I am reading "Wicket in Action" the part over wicket, spring and > hibernate.Since i am new to concepts like wicket, spring and hibernate i > want to learn about them.But also learning three new tools together is a > bit much. > Is it therefore a good idea to forget about Spring and make the mvc > working with only Wicket and Hibernate? > Maybe you can give me a startup voor working together wicket and hibernate? > Thanks a lot! > Greetings Gerrit
Using Wicket and Hibernate
Hello, I am reading "Wicket in Action" the part over wicket, spring and hibernate.Since i am new to concepts like wicket, spring and hibernate i want to learn about them.But also learning three new tools together is a bit much. Is it therefore a good idea to forget about Spring and make the mvc working with only Wicket and Hibernate? Maybe you can give me a startup voor working together wicket and hibernate? Thanks a lot! Greetings Gerrit
Re: Using Wicket and Hibernate
Thanks! Dan Alvizu , 21-11-2013 14:59: Here's an example of wicket spring and hibernate all working together, with an h2 database: https://github.com/dalvizu/wicket-spring-hibernate-template -Dan On Thu, Nov 21, 2013 at 8:30 AM, Gerrit Wassink wrote: > Hello, > I am reading "Wicket in Action" the part over wicket, spring and > hibernate.Since i am new to concepts like wicket, spring and hibernate i > want to learn about them.But also learning three new tools together is a > bit much. > Is it therefore a good idea to forget about Spring and make the mvc > working with only Wicket and Hibernate? > Maybe you can give me a startup voor working together wicket and hibernate? > Thanks a lot! > Greetings Gerrit
Re: looking for example wicket and hibernate
Hi we have been starting with our hibernate/spring/wicket app a few weeks ago and its quite easy. We do it with maven2 like this: i show you some snippets, please ask me if you have any further questions: in your pom.xml: = 1.4.5 ... org.apache.wicket wicket ${wicket.version} org.apache.wicket wicket-extensions ${wicket.version} org.apache.wicket wicket-spring ${wicket.version} org.springframework spring web.xml = http://java.sun.com/xml/ns/j2ee"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"; version="2.4"> wicket wicket.wicket org.apache.wicket.protocol.http.WicketFilter applicationClassName org.yourapp.MyApplication wicket.wicket /* you can start the spring context directly in your web.xml, but I wanted to start my SpringApplication manually in my Application class: in your MyApplication.java = public class MyApplication extends WebApplication @Override protected void init ( ) { WebApplicationContext ctx = start_your_spring_context_here addComponentInstantiationListener(new SpringComponentInjector(this, ctx, true)); } @Override public RequestCycle newRequestCycle ( Request request, Response response ) { return new HibernateRequestCycle(this, (WebRequest) request, (WebResponse) response); } our session per RequestCycle Implemenatation: = public class HibernateRequestCycle extends WebRequestCycle { SessionFactory sessionFactory; public HibernateRequestCycle ( JlotApplication application, WebRequest request, Response response ) { super(application, request, response); this.sessionFactory = (SessionFactory) application.getApplicationContext().getBean("sessionFactory"); } @Override protected void onBeginRequest ( ) { if (!TransactionSynchronizationManager.hasResource(sessionFactory)) { Session session = SessionFactoryUtils.getSession(sessionFactory, true); TransactionSynchronizationManager.bindResource(sessionFactory, new SessionHolder(session)); } super.onBeginRequest(); } @Override protected void onEndRequest ( ) { SessionHolder sessionHolder = (SessionHolder) TransactionSynchronizationManager.unbindResource(sessionFactory); SessionFactoryUtils.closeSession(sessionHolder.getSession()); super.onEndRequest(); } } wherever you need a Spring bean you can inject it like this: @SpringBean Repository repository; public MyClass() { InjectorHolder.getInjector().inject(this); } if you have a wicket component you do not need this line: InjectorHolder.getInjector().inject(this); then read about detachable Models! Its quite important to understand it if you use hibernate. we use an entityModel like this one: http://wicketinaction.com/2008/09/building-a-smart-entitymodel/ if you like i can send you more source code, but i got it working just by reading "wicket in action", which is am excellent book. our software will be open source soon, so i can send you the complete source code if you like. kind regards Janning On Thursday 24 December 2009 06:42:57 Johan den Boer wrote: > Hi > > I am looking for a real working example on wicket and hibernate. I have > read the books 'Wcket in Action', 'Pro Wicket' and other books but none of > them give a real working example. Can somebody point me to a real working > example or can sent to me. > > The most problem i have with the configuration in web.xml and using the > spring integration. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: looking for example wicket and hibernate
Theres also wicket Iolite, or I think the legup by jweekend.. 2009/12/24 Martin Makundi : > Do not mix hibernate and wicket (web gui). Keep your persistence logic > somewhere else. > > However, if you want only wicket-spring integration you can find some > here: http://www.wicket-library.com/wicket-examples/spring/ > > ** > Martin > > 2009/12/24 Johan den Boer : >> Hi >> >> I am looking for a real working example on wicket and hibernate. I have read >> the books 'Wcket in Action', 'Pro Wicket' and other books but none of them >> give a real working example. Can somebody point me to a real working example >> or can sent to me. >> >> The most problem i have with the configuration in web.xml and using the >> spring integration. >> >> -- >> regards, >> >> John >> > > - > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > > - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: looking for example wicket and hibernate
Do not mix hibernate and wicket (web gui). Keep your persistence logic somewhere else. However, if you want only wicket-spring integration you can find some here: http://www.wicket-library.com/wicket-examples/spring/ ** Martin 2009/12/24 Johan den Boer : > Hi > > I am looking for a real working example on wicket and hibernate. I have read > the books 'Wcket in Action', 'Pro Wicket' and other books but none of them > give a real working example. Can somebody point me to a real working example > or can sent to me. > > The most problem i have with the configuration in web.xml and using the > spring integration. > > -- > regards, > > John > - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
looking for example wicket and hibernate
Hi I am looking for a real working example on wicket and hibernate. I have read the books 'Wcket in Action', 'Pro Wicket' and other books but none of them give a real working example. Can somebody point me to a real working example or can sent to me. The most problem i have with the configuration in web.xml and using the spring integration. -- regards, John
Re: wicket and hibernate
You said you were using annotations. Just read chapter 1 of the hibernate annotations docs http://www.hibernate.org/hib_docs/annotations/reference/en/html_single/#setup-configuration create a class called HibernateUtil.class (or you can call it Fluffy.class, but that's not as descriptive) and add a static SessionFactory. public static final SessionFactory sessionFactory; Then add an initialize method to add your annotated classes with this: AnnotationConfiguration cfg = new AnnotationConfiguration(); cfg.configure(); sessionFactory = cfg .setInterceptor(new AuditInterceptor()) .addAnnotatedClass(User.class) //others as needed .buildSessionFactory(); The WebApplication object for your project has an init() method. You can call the above method from there. When wicket starts up, it will call that init() method first, so you can do things like setup your app. Or just wrap the above in a static block and you don't have to worry about it. The first time you access the HibernateUtil, the class loader will run the static block. Then in your methods you can just get a connection from the pool. Session session = HibernateUtil.sessionFactory.openSession(); I do this a little differently than hibernate examples. In the service, I open the connection, get all the data I need and close the connection at the end of the method. The way Hibernate works is when your working thread gets a connection, hibernate attaches that connection to the thread. So throughout the lifecycle you can make references to related objects and hibernate will go fetch them for you. I don't like that technique, personally. HTH -- View this message in context: http://www.nabble.com/wicket-and-hibernate-tp19767474p19791416.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: wicket and hibernate
models. > > The only catch with this is your web layer is getting hibernate > aware models, not POJOs. So if it's a closed system where nobody > else hits your hibernate code, you're fine. If the service layer > is an SOA type arch, you'll need to convert your hibernate models > (or the list), to equivalent pojos on select and vice-versa on saves. > > > The only thing I did which I regret was I defined my collections > in hibernate as Lists instead of sets. I did this because wicket > takes a list as a param in a lot of places and Lists are generally > easier to work with. > > But hibernate treats Lists as bags and when you are doing eager fetches > on multiple collections, Hibernate will complain. > It won't let you fetch multiple bags simultaneously. It used to though. > They keep threatening to fix it. > > http://opensource.atlassian.com/projects/hibernate/browse/HHH-1718 > > -- View this message in context: http://www.nabble.com/wicket-and-hibernate-tp19767474p19773409.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: wicket and hibernate
Here's how I do it. I have my wicket layer call a service layer, which calls a DAO. I'm not a big fan of a lot of layers and I like to keep my projects flat. So, if you want a list of users on a page, for example, you can use any of the canned wicket tables. Those are pretty nice. I use DefaultDataTable unless I need something special. So in your page class you do something like DefaultDataTable defaultDataTable = new DefaultDataTable("table", columnsList, new SortableUserDataProvider(userFilter), 10); If this doesn't make sense look at the DefaultDataTable.java class in the wicket examples. In my SortableUserDataProvider, I pass in a filter obj depending on what the user is asking for. This includes any search criteria, sort options, paging, etc. My SortableUserDataProvider calls my service. That preps the hibernate query and calls my dao. So for the SortableUserDataProvider you want to override the iterator() method, something like: public Iterator iterator(int first, int count) { SortParam sp = getSort(); userFilter.setFirstRecord(first); userFilter.setRecordsToReturn(count); userFilter.setSortCol(sp.getProperty()); userFilter.setSortAsc(sp.isAscending()); return UserService.getUsers(userFilter).iterator(); } I prep my queries in my service layer. So something like Criteria userCriteria = session.createCriteria(User.class) .setFirstResult(filter.getFirstRecord()) //other filter info here as needed List userList = userCriteria.list(); Hibernate returns models and lists of models, and wicket uses models and lists of models. The only catch with this is your web layer is getting hibernate aware models, not POJOs. So if it's a closed system where nobody else hits your hibernate code, you're fine. If the service layer is an SOA type arch, you'll need to convert your hibernate models (or the list), to equivalent pojos on select and vice-versa on saves. The only thing I did which I regret was I defined my collections in hibernate as Lists instead of sets. I did this because wicket takes a list as a param in a lot of places and Lists are generally easier to work with. But hibernate treats Lists as bags and when you are doing eager fetches on multiple collections, Hibernate will complain. It won't let you fetch multiple bags simultaneously. It used to though. They keep threatening to fix it. http://opensource.atlassian.com/projects/hibernate/browse/HHH-1718 -- View this message in context: http://www.nabble.com/wicket-and-hibernate-tp19767474p19772328.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: wicket and hibernate
Hi, Have a look at http://wicketstuff.org/confluence/display/STUFFWIKI/Wicket-Iolite overseastars a écrit : Hi I just wanna know how to integrate wicket and hibernate?? can someone give me a simple example even just one entity is ok. I have my entities(hibernate annotation) ready and I have no ideas of making them work together. If any buddy can send me an example project, I will really appreciate it. Thanks in advance. Regards - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
wicket and hibernate
Hi I just wanna know how to integrate wicket and hibernate?? can someone give me a simple example even just one entity is ok. I have my entities(hibernate annotation) ready and I have no ideas of making them work together. If any buddy can send me an example project, I will really appreciate it. Thanks in advance. Regards -- View this message in context: http://www.nabble.com/wicket-and-hibernate-tp19767474p19767474.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Lazy load exception wicket and hibernate
On Sun, Mar 30, 2008 at 6:01 AM, lars vonk <[EMAIL PROTECTED]> wrote: > IIRC you should put the OpenEntityManagerInViewFilter definition in the > > filter-mapping after the WicketFilter otherwise the WicketFilter will come > > first. > > > I of course meant *before the WicketFilter*, because like I stated later on > in the mail that it's the definition of the *filter-mapping* element that > depicts the order of execution. So we are all on the same page here :-). Yes, that's what I was originally questioning. I figured it was a typo, but I wanted to make sure, because I always thought it was the other way around. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Lazy load exception wicket and hibernate
Sorry, my bad. I made a typo earlier what may have caused the confusion: > On Sat, Mar 29, 2008 at 7:15 AM, lars vonk <[EMAIL PROTECTED]> wrote: IIRC you should put the OpenEntityManagerInViewFilter definition in the > filter-mapping after the WicketFilter otherwise the WicketFilter will come > first. I of course meant *before the WicketFilter*, because like I stated later on in the mail that it's the definition of the *filter-mapping* element that depicts the order of execution. So we are all on the same page here :-). Lars On Sun, Mar 30, 2008 at 8:17 AM, Igor Vaynberg <[EMAIL PROTECTED]> wrote: > On Sat, Mar 29, 2008 at 8:04 PM, James Carman > <[EMAIL PROTECTED]> wrote: > > So, I think you just have it backwards. The > > OpenEntityManagerInViewFilter should be mapped before the > > WicketFilter. > > i dont know if my english is broken or what, but i believe that is > exactly what ive been saying all along... > > -igor > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > >
Re: Lazy load exception wicket and hibernate
On Sat, Mar 29, 2008 at 8:04 PM, James Carman <[EMAIL PROTECTED]> wrote: > So, I think you just have it backwards. The > OpenEntityManagerInViewFilter should be mapped before the > WicketFilter. i dont know if my english is broken or what, but i believe that is exactly what ive been saying all along... -igor - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Lazy load exception wicket and hibernate
On Sat, Mar 29, 2008 at 10:14 PM, Igor Vaynberg <[EMAIL PROTECTED]> wrote: > it will execute _after_ the wicket filter. which is no good because > you need lazy loading to work inside wicket filter, so you need oemiv > to execute before. and possibly, if wicket filter never calls > chain.dofilter it will never execute. I mean, are you sure it will execute after? I just did a simple test: public class Filter1 implements Filter { public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { System.out.println("Entering Filter1..."); filterChain.doFilter(servletRequest, servletResponse); System.out.println("Exiting Filter1..."); } } public class Filter2 implements Filter { public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { System.out.println("Entering Filter2..."); filterChain.doFilter(servletRequest, servletResponse); System.out.println("Exiting Filter2..."); } } filter1 com.mycompany.Filter1 filter2 com.mycompany.Filter2 filter1 /* filter2 /* wicket.myproject /* When I access my HomePage, it prints out: Entering Filter1... Entering Filter2... Exiting Filter2... Exiting Filter1... So, I think you just have it backwards. The OpenEntityManagerInViewFilter should be mapped before the WicketFilter. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Lazy load exception wicket and hibernate
it will execute _after_ the wicket filter. which is no good because you need lazy loading to work inside wicket filter, so you need oemiv to execute before. and possibly, if wicket filter never calls chain.dofilter it will never execute. -igor On Sat, Mar 29, 2008 at 7:02 PM, James Carman <[EMAIL PROTECTED]> wrote: > On Sat, Mar 29, 2008 at 7:15 AM, lars vonk <[EMAIL PROTECTED]> wrote: > > > What is the order of the filters you defined in your filter-mapping element > > in the web.xml. IIRC you should put the OpenEntityManagerInViewFilter > > definition in the filter-mapping after the WicketFilter otherwise the > > WicketFilter will come first. > > I don't understand what you mean here. Are you saying that if I do this: > > > oemiv > /* > > > > wicket > /* > > > then the WicketFilter will execute first and the "oemiv" filter won't > ever execute? > > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Lazy load exception wicket and hibernate
On Sat, Mar 29, 2008 at 7:15 AM, lars vonk <[EMAIL PROTECTED]> wrote: > What is the order of the filters you defined in your filter-mapping element > in the web.xml. IIRC you should put the OpenEntityManagerInViewFilter > definition in the filter-mapping after the WicketFilter otherwise the > WicketFilter will come first. I don't understand what you mean here. Are you saying that if I do this: oemiv /* wicket /* then the WicketFilter will execute first and the "oemiv" filter won't ever execute? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Lazy load exception wicket and hibernate
gt; > >} > > > >}); > > > >} > > > > > > > >class ListOwnerProvider implements IDataProvider { > > > > > > > >private static final long serialVersionUID = 1L; > > > > > > > >@Override > > > >public void detach() { > > > > > > > > > > > >} > > > > > > > >@Override > > > >public Iterator iterator(int first, int count) { > > > >return testService.getListOwners > > > > (first,count).iterator(); > > > >} > > > > > > > >@Override > > > >public IModel model(Object object) { > > > > > > > >return new CompoundPropertyModel(new > > > > ListOwnerModel((ListOwner)object)); > > > > } > > > > > > > >@Override > > > >public int size() { > > > >return testService.getListOwners().size(); > > > >} > > > >} > > > > > > > >class ListOwnerModel extends LoadableDetachableModel { > > > >private static final long serialVersionUID = 1L; > > > >private Integer id; > > > > > > > >public ListOwnerModel(ListOwner listOwner) { > > > >this.id = listOwner.getId(); > > > >} > > > > > > > >@Override > > > >protected Object load() { > > > >return testService.getListOwner(id); > > > > } > > > >} > > > > } > > > > > > > > > > > > > > > > Mathias P.W Nilsson wrote: > > > > > > > > > > I'm using wicket with hibernate and spring. In my web.xml I have > > > > > OpenEntityManagerInViewFilter. But when trying to add a dataview to > > my > > > > > wicket page I get the org.hibernate.LazyInitializationException > > > > > > > > > > > > > -- > > > > View this message in context: > > > > > > > http://www.nabble.com/Lazy-load-exception-wicket-and-hibernate-tp15976668p16361116.html > > > > Sent from the Wicket - User mailing list archive at Nabble.com. > > > > > > > > > > > > > - > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Lazy load exception wicket and hibernate
} > > > > > >@Override > > >public int size() { > > >return testService.getListOwners().size(); > > >} > > >} > > > > > > class ListOwnerModel extends LoadableDetachableModel { > > >private static final long serialVersionUID = 1L; > > >private Integer id; > > > > > >public ListOwnerModel(ListOwner listOwner) { > > >this.id = listOwner.getId(); > > >} > > > > > >@Override > > >protected Object load() { > > >return testService.getListOwner(id); > > > } > > >} > > > } > > > > > > > > > > > > Mathias P.W Nilsson wrote: > > > > > > > > I'm using wicket with hibernate and spring. In my web.xml I have > > > > OpenEntityManagerInViewFilter. But when trying to add a dataview to > my > > > > wicket page I get the org.hibernate.LazyInitializationException > > > > > > > > > > -- > > > View this message in context: > > > > http://www.nabble.com/Lazy-load-exception-wicket-and-hibernate-tp15976668p16361116.html > > > Sent from the Wicket - User mailing list archive at Nabble.com. > > > > > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > >
Re: Lazy load exception wicket and hibernate
erm, i thought filters were executed in the order they were defined in web.xml. so open..inview should be declared before wicket. and its not the filter-mapping but the filter element... -igor On Sat, Mar 29, 2008 at 4:15 AM, lars vonk <[EMAIL PROTECTED]> wrote: > What is the order of the filters you defined in your filter-mapping element > in the web.xml. IIRC you should put the OpenEntityManagerInViewFilter > definition in the filter-mapping after the WicketFilter otherwise the > WicketFilter will come first. > > Lars > > > > On Fri, Mar 28, 2008 at 9:11 PM, cjlyth <[EMAIL PROTECTED]> wrote: > > > > > I have been getting the same error. I feel like im missing something. > > Maybe I > > am doing something horibly wrong but I haven't been able to figure out > > what > > it is. > > > > I am using spring 2.5, Wicket 1.3.2, and I have put the > > OpenEntityManagerInViewFilter in my web xml. The filter is loading ok, im > > not sure what to do next... > > > > If anyone can help please let me know what you need to see. I even have an > > example application i can upload. > > I am using a DataView, I have tried to inject the spring beans into every > > part (data provider, etc) and I always get the same result... > > For now I will include the wicket stuff: > > > > > > public class Home extends WebPage { > >@SpringBean > >private TestService testService; > > > >public Home() { > >init(); > >} > > > >public Home(PageParameters parameters) { > >super(parameters); > >init(); > >} > > > >private void init() { > >add(new DataView("container", new ListOwnerProvider()) { > >private static final long serialVersionUID = 1L; > > > >@Override > >protected void populateItem(Item item) { > >/*ListOwner owner = > > (ListOwner)item.getModelObject();*/ > >item.add(new Label("name")); > >item.add(new ListView("entries"){ > >private static final long > > serialVersionUID = 1L; > > > >@Override > >protected void > > populateItem(ListItem item) { > >item.add(new > > Label("value")); > >} > >}); > >} > >}); > >} > > > >class ListOwnerProvider implements IDataProvider { > > > >private static final long serialVersionUID = 1L; > > > >@Override > >public void detach() { > > > > > >} > > > >@Override > >public Iterator iterator(int first, int count) { > >return testService.getListOwners > > (first,count).iterator(); > >} > > > >@Override > >public IModel model(Object object) { > > > >return new CompoundPropertyModel(new > > ListOwnerModel((ListOwner)object)); > >} > > > >@Override > >public int size() { > >return testService.getListOwners().size(); > >} > >} > > > >class ListOwnerModel extends LoadableDetachableModel { > >private static final long serialVersionUID = 1L; > >private Integer id; > > > >public ListOwnerModel(ListOwner listOwner) { > > this.id = listOwner.getId(); > >} > > > >@Override > >protected Object load() { > >return testService.getListOwner(id); > > } > >} > > } > > > > > > > > Mathias P.W Nilsson wrote: > > > > > > I'm using wicket with hibernate and spring. In my web.xml I have > > > OpenEntityManagerInViewFilter. But when trying to add a dataview to my > > > wicket page I get the org.hibernate.LazyInitializationException > > > > > > > -- > > View this message in context: > > > http://www.nabble.com/Lazy-load-exception-wicket-and-hibernate-tp15976668p16361116.html > > Sent from the Wicket - User mailing list archive at Nabble.com. > > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Lazy load exception wicket and hibernate
What is the order of the filters you defined in your filter-mapping element in the web.xml. IIRC you should put the OpenEntityManagerInViewFilter definition in the filter-mapping after the WicketFilter otherwise the WicketFilter will come first. Lars On Fri, Mar 28, 2008 at 9:11 PM, cjlyth <[EMAIL PROTECTED]> wrote: > > I have been getting the same error. I feel like im missing something. > Maybe I > am doing something horibly wrong but I haven't been able to figure out > what > it is. > > I am using spring 2.5, Wicket 1.3.2, and I have put the > OpenEntityManagerInViewFilter in my web xml. The filter is loading ok, im > not sure what to do next... > > If anyone can help please let me know what you need to see. I even have an > example application i can upload. > I am using a DataView, I have tried to inject the spring beans into every > part (data provider, etc) and I always get the same result... > For now I will include the wicket stuff: > > > public class Home extends WebPage { >@SpringBean >private TestService testService; > >public Home() { >init(); >} > >public Home(PageParameters parameters) { >super(parameters); >init(); >} > >private void init() { >add(new DataView("container", new ListOwnerProvider()) { >private static final long serialVersionUID = 1L; > >@Override >protected void populateItem(Item item) { >/*ListOwner owner = > (ListOwner)item.getModelObject();*/ >item.add(new Label("name")); >item.add(new ListView("entries"){ >private static final long > serialVersionUID = 1L; > >@Override >protected void > populateItem(ListItem item) { >item.add(new > Label("value")); >} >}); >} >}); >} > >class ListOwnerProvider implements IDataProvider { > >private static final long serialVersionUID = 1L; > >@Override >public void detach() { > > >} > >@Override >public Iterator iterator(int first, int count) { >return testService.getListOwners > (first,count).iterator(); >} > >@Override >public IModel model(Object object) { > >return new CompoundPropertyModel(new > ListOwnerModel((ListOwner)object)); >} > >@Override >public int size() { >return testService.getListOwners().size(); >} >} > >class ListOwnerModel extends LoadableDetachableModel { >private static final long serialVersionUID = 1L; >private Integer id; > >public ListOwnerModel(ListOwner listOwner) { >this.id = listOwner.getId(); >} > >@Override >protected Object load() { >return testService.getListOwner(id); > } >} > } > > > > Mathias P.W Nilsson wrote: > > > > I'm using wicket with hibernate and spring. In my web.xml I have > > OpenEntityManagerInViewFilter. But when trying to add a dataview to my > > wicket page I get the org.hibernate.LazyInitializationException > > > > -- > View this message in context: > http://www.nabble.com/Lazy-load-exception-wicket-and-hibernate-tp15976668p16361116.html > Sent from the Wicket - User mailing list archive at Nabble.com. >
Re: Lazy load exception wicket and hibernate
I have been getting the same error. I feel like im missing something. Maybe I am doing something horibly wrong but I haven't been able to figure out what it is. I am using spring 2.5, Wicket 1.3.2, and I have put the OpenEntityManagerInViewFilter in my web xml. The filter is loading ok, im not sure what to do next... If anyone can help please let me know what you need to see. I even have an example application i can upload. I am using a DataView, I have tried to inject the spring beans into every part (data provider, etc) and I always get the same result... For now I will include the wicket stuff: public class Home extends WebPage { @SpringBean private TestService testService; public Home() { init(); } public Home(PageParameters parameters) { super(parameters); init(); } private void init() { add(new DataView("container", new ListOwnerProvider()) { private static final long serialVersionUID = 1L; @Override protected void populateItem(Item item) { /*ListOwner owner = (ListOwner)item.getModelObject();*/ item.add(new Label("name")); item.add(new ListView("entries"){ private static final long serialVersionUID = 1L; @Override protected void populateItem(ListItem item) { item.add(new Label("value")); } }); } }); } class ListOwnerProvider implements IDataProvider { private static final long serialVersionUID = 1L; @Override public void detach() { } @Override public Iterator iterator(int first, int count) { return testService.getListOwners(first,count).iterator(); } @Override public IModel model(Object object) { return new CompoundPropertyModel(new ListOwnerModel((ListOwner)object)); } @Override public int size() { return testService.getListOwners().size(); } } class ListOwnerModel extends LoadableDetachableModel { private static final long serialVersionUID = 1L; private Integer id; public ListOwnerModel(ListOwner listOwner) { this.id = listOwner.getId(); } @Override protected Object load() { return testService.getListOwner(id); } } } Mathias P.W Nilsson wrote: > > I'm using wicket with hibernate and spring. In my web.xml I have > OpenEntityManagerInViewFilter. But when trying to add a dataview to my > wicket page I get the org.hibernate.LazyInitializationException > -- View this message in context: http://www.nabble.com/Lazy-load-exception-wicket-and-hibernate-tp15976668p16361116.html Sent from the Wicket - User mailing list archive at Nabble.com.
Re: Lazy load exception wicket and hibernate
Show us some code, please. How are you setting things up? On 3/11/08, Mathias P.W Nilsson <[EMAIL PROTECTED]> wrote: > > Not exactly sure what you mean here since this is my first time trying wicket > and hibernate, spring. > > I have spring annoted daos that I use myDao().getList(); returns a list that > has lazy object references. > When I try to evoke a method on the lazy object i get the exception. I have > solved i right now with DTO but it seam total meaningless to have dto when > all my entities can be used in the wicket page. > > > > -- > View this message in context: > http://www.nabble.com/Lazy-load-exception-wicket-and-hibernate-tp15976668p15988359.html > > Sent from the Wicket - User mailing list archive at Nabble.com. > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Lazy load exception wicket and hibernate
Not exactly sure what you mean here since this is my first time trying wicket and hibernate, spring. I have spring annoted daos that I use ex. myDao().getList(); returns a list that has lazy object references. When I try to evoke a method on the lazy object I get the exception. I have solved i right now with DTO but it seam total meaningless to have dto when all my entities can be used in the wicket page. -- View this message in context: http://www.nabble.com/Lazy-load-exception-wicket-and-hibernate-tp15976668p15988359.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Lazy load exception wicket and hibernate
On 3/11/08, Mathias P.W Nilsson <[EMAIL PROTECTED]> wrote: > > Hi! > > I'm using wicket with hibernate and spring. In my web.xml I have > OpenEntityManagerInViewFilter. But when trying to add a dataview to my > wicket page I get the org.hibernate.LazyInitializationException: could not > initialize proxy - the owning Session was closed. Anyone? Are you using a detachable model or is the entity being stored with the page (serialized)? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Lazy load exception wicket and hibernate
Hi! I'm using wicket with hibernate and spring. In my web.xml I have OpenEntityManagerInViewFilter. But when trying to add a dataview to my wicket page I get the org.hibernate.LazyInitializationException: could not initialize proxy - the owning Session was closed. Anyone? -- View this message in context: http://www.nabble.com/Lazy-load-exception-wicket-and-hibernate-tp15976668p15976668.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]