I had lots of problems with a Spring MVC webapp that was using
OpenSessionInViewFilter : beans were associated directly in DB when they
were added to a collection (like the current Foo/Bar case) even if I didn't
commit explicitly.
Without the session opened, I can prepare all my entities and just save them
and commit.

I use this filter on another webapp that just load entities form DB but does
not update them. It works perfectly!

I though I would have the same kind of errors with Wicket because this is
not a Wicket part but just a Hibernate functionality.

If in my case, I use the filter, the Bar.foos association will be loaded
just on demand but if I add it a new created Foo entity (transient), it will
try to save it on flush (so before my save/commit) and I will have an
exception.
Maybe I'm wrong but I remember this kind of errors with Spring MVC...

Cedric


On Tue, Sep 16, 2008 at 10:16 AM, James Carman
<[EMAIL PROTECTED]>wrote:

> What problems does it cause?
>
> On Tue, Sep 16, 2008 at 9:14 AM, Cédric Thiébault
> <[EMAIL PROTECTED]> wrote:
> > Thanks Michael.
> >
> > But I don't use the OpenSessionInviewFilter and I don't want to use it.
> > It creates more problems than it solves in my edit pages.
> >
> > The LoadableDetachableModel will load the whole list of choices, not
> > just the one that was selected by the user.
> > I will encounter the same error except if the
> > LoadableDetachableModel.load method pre-fetch the associations...
> >
> > Cedric
> >
> >
> > On Tue, Sep 16, 2008 at 3:01 AM, Michael Sparer <[EMAIL PROTECTED]>
> wrote:
> >>
> >> Use LoadableDetachableModels (and be sure that the
> OpensessionInviewFilter
> >> goes before the wicketfilter) and your hibernate entity will always be
> in
> >> the right session
> >>
> >> regards,
> >> Michael
> >>
> >> thiebal wrote:
> >>>
> >>> My DropDownChoice contains a list of hibernate entities that are not
> >>> fully loaded.
> >>> But when I select a value in the dropdown I receive a
> >>> LazyLoadingException because Wicket tries to add an entry in a
> >>> collection that was not previously loaded.
> >>>
> >>> I tried to use a Converter but it is not called because
> >>> PropertyResolverConverter set directly the value (because their
> >>> classes are compatible) :
> >>> if (clz.isAssignableFrom(object.getClass())) {
> >>>   return object;
> >>> }
> >>>
> >>> It works if I preload each entry in the list of choices of the
> >>> DropDownChoice but it is very expensive. To display the dropdown, I
> >>> just need to retrieve the name of my hibernate entity, not the
> >>> collection inside this bean.
> >>> I would like to load the collection only when the user select an
> >>> option in the select.
> >>>
> >>> Code :
> >>> class Foo {
> >>>   Bar bar;
> >>>
> >>>   void setBar(Bar bar) {
> >>>     this.bar = bar;
> >>>     bar.getFoos().add(this);  // this will throw a
> >>> LazyLoadingException if I don't fetch the collections before I render
> >>> the DropDownChoice
> >>>   }
> >>> }
> >>>
> >>> class Bar {
> >>>   Collection<Foo> foos;
> >>> }
> >>>
> >>> Is there a nice way to do that ?
> >>>
> >>> Thanks in advance :-)
> >>>
> >>> Cedric
> >>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: [EMAIL PROTECTED]
> >>> For additional commands, e-mail: [EMAIL PROTECTED]
> >>>
> >>>
> >>>
> >>
> >>
> >> -----
> >> Michael Sparer
> >> http://talk-on-tech.blogspot.com
> >> --
> >> View this message in context:
> http://www.nabble.com/DropDownChoice-and-lazy-loaded-choices-tp19501118p19506463.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]
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

Reply via email to