Right, I was going to suggest you not use multiple.  That does lead to
problems if you're not careful.

Anyway, in your situation, you're holding onto a "detached" object?
And, it's somehow getting loaded (huh huh, I said "getting loaded")
somewhere else during the same request?



On Thu, Sep 18, 2008 at 10:31 AM, Cédric Thiébault
<[EMAIL PROTECTED]> wrote:
> I tried both but it was worst with multiple session because entities
> were already associated in an other session and it throws
> exceptions...
>
>
> On Thu, Sep 18, 2008 at 10:17 AM, James Carman
> <[EMAIL PROTECTED]> wrote:
>> Are you using the single session setting on OSIV?  Or, are you using
>> multiple sessions?
>>
>> On Thu, Sep 18, 2008 at 9:12 AM, Cédric Thiébault
>> <[EMAIL PROTECTED]> wrote:
>>> In fact my example with the collection updating automatically was
>>> wrong... because, as it was said, the transaction is not committed at
>>> the end.
>>>
>>> But I remember other kind of problems when I wanted to save and commit
>>> my modified entities after I loaded and associated them during the
>>> request (via OSIV) :
>>> I was passing a graph of persistent objects to the manager and I had
>>> exception like "a different object with the same identifier value was
>>> already associated with the session".
>>> I tried then to use a merge but in this case I had other exception (I
>>> don't remember exactly which one)...
>>>
>>> If I don't use OSIV and pass a graph of transient object, it works fine!
>>>
>>> It must be something wrong with my hibernate mapping but it hard to locate 
>>> :-(
>>>
>>> Cedric
>>>
>>>
>>> On Thu, Sep 18, 2008 at 3:26 AM, Maarten Bosteels
>>> <[EMAIL PROTECTED]> wrote:
>>>>
>>>> Hi,
>>>>
>>>> I never really used OpenSessionInViewFilter, but I remember Juergen
>>>> Hoeller saying that he sometimes wished he never wrote OSIV because of
>>>> all the potential side-effects.
>>>> At the time a ridiculous big percentage of questions on the spring
>>>> forum where about OSIV.
>>>>
>>>> This was several years ago though, and I have the impression that a
>>>> lot of people are using OSIV now without problems.
>>>>
>>>> I guess it all works fine when you know what you're doing :-)
>>>>
>>>> Maarten
>>>>
>>>>
>>>> On Tue, Sep 16, 2008 at 10:28 PM, Cédric Thiébault
>>>> <[EMAIL PROTECTED]> wrote:
>>>> > Ok thanks all...
>>>> > I will read again about Hibernate sessions :-)
>>>> >
>>>> > Cedric
>>>> >
>>>> >
>>>> > On Tue, Sep 16, 2008 at 4:26 PM, Igor Vaynberg <[EMAIL PROTECTED]>wrote:
>>>> >
>>>> >> +1
>>>> >>
>>>> >> -igor
>>>> >>
>>>> >> On Tue, Sep 16, 2008 at 1:24 PM, James Carman
>>>> >> <[EMAIL PROTECTED]> wrote:
>>>> >> > +1, OSIV works for me just fine, too.  You must be doing something
>>>> >> > weird.  The OSIV doesn't commit transactions by default.  So, it
>>>> >> > shouldn't be doing anything weird.
>>>> >> >
>>>> >> > On Tue, Sep 16, 2008 at 1:07 PM, Michael Sparer <[EMAIL PROTECTED]>
>>>> >> wrote:
>>>> >> >>
>>>> >> >> Before dropping OpenSessionInviewFilter I'd suggest to have a more
>>>> >> thorough
>>>> >> >> look at how hibernate works. e.g. have a look at the different 
>>>> >> >> cascade
>>>> >> >> styles hibernate offers and also at transaction management, then it's
>>>> >> easy
>>>> >> >> to know why, and when, hibernate "commits" without explicitly calling
>>>> >> save
>>>> >> >> ... but that's no wicket topic after all. I'm using
>>>> >> opensessioninviewfilter
>>>> >> >> with loadabledetachablemodels in my webapp and never had problems ...
>>>> >> >>
>>>> >> >> just my two cents,
>>>> >> >> Michael
>>>> >> >>
>>>> >> >>
>>>> >> >> thiebal wrote:
>>>> >> >>>
>>>> >> >>> 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]
>>>> >> >>>>
>>>> >> >>>>
>>>> >> >>>
>>>> >> >>>
>>>> >> >>
>>>> >> >>
>>>> >> >> -----
>>>> >> >> Michael Sparer
>>>> >> >> http://talk-on-tech.blogspot.com
>>>> >> >> --
>>>> >> >> View this message in context:
>>>> >> http://www.nabble.com/DropDownChoice-and-lazy-loaded-choices-tp19501118p19516254.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]
>>>> >>
>>>> >>
>>>> >
>>>
>>> ---------------------------------------------------------------------
>>> 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]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to