this is not very difficult to fix. there are really only two basic rules: 1) never keep direct references to hibernate entities. this is because they will become detached between request and unless you call session.lock/refresh on them before accessing a collection you will get the lazy exception. instead, use detachable models such as the loadabledetachablemodel to give components access to entities.
2) install spring's opensessioninview filter that runs around the wicket filter. by default spring's transactionam support will create a session per transaction, by the time wicket will render the page the session will be closed along with the transaction. having the filter will ensure spring uses session-per-request pattern and reuse the same session for multiple transactions when possible. since the filter is around wicket's the session will still be open when wicket renders the page. for an example you can see wicket-phonebook app in wicket-stuff's svn. -igor On Sat, May 3, 2008 at 4:20 PM, Mathias P.W Nilsson <[EMAIL PROTECTED]> wrote: > > Is there any good tutorial on wicket, hibernate and spring? When dealing with > my lazy many to one relations I get lazy loading exception. Very annoing. > > Lets say I have an Item class that has many to one relations to a category. > I list the items in a wicket page and when click a link I do > setResponsePage( new ItemPage( item ) ); > > when getting to this page I get a lazy loading exception on the category. > How's that? I thought that open session in view should allow this. Is there > any way of dealing with this? > -- > View this message in context: > http://www.nabble.com/How-to-avoid-Lazy-loading-exception-tp17040941p17040941.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]
