But you can't load the object every time, you have to keep it around
in memory between requests. Right now I do load it on each request,
but it's proxied.

So here's what I'm seeing:

-Use maps, then transfer to the domain models.

-Load the object once, then hold on to it so that the session expires
and it can't be automatically merged.

-Load and detatch the object on every request, but make sure it's unproxied.

-Clone the object at some point so that you can revert if needed.

The first one makes a lot of lines, and gets tricky in a repeating
view. The second one keeps data around between requests and the third
one doesn't give you access to lazy collections. The last one... I
don't even know how I'd go about doing that, and I have a feeling that
Hibernate would get lost and update anyway.

I think I'm going to give the second or third option a go. You
shouldn't have to rely on lazy loading collections anyway (or so the
Hibernate guys tell me :)). Thanks for helping me brainstorm, guys!

On 11/2/05, Eelco Hillenius <[EMAIL PROTECTED]> wrote:
> Yeah, that's probably the nicest solution. You have to reload your
> object every request though, otherwise you'll have your dirty object
> still. But that's a good idea with Hibernate objects anyway,
> especially when they have lazy relations.
>
> Eelco
>
>
> On 11/2/05, Igor Vaynberg <[EMAIL PROTECTED]> wrote:
> > in a current project i have to do the validation in the service layer, so i
> > had the same problem. i use detached objects, and session.merge(). its a
> > very clean solution and works great so far.
> >
> >  basic idea is: when creating an edit page load the object from database and
> > set it as form model. when the form is submitted - the loaded object becomes
> > detached because its session was closed when the prev request was done. let
> > the form bean the changes. call the service validate method - if everything
> > is OK - call the service merge method which uses session.merge to save the
> > changes.
> >
> >  checkout wicket-phonebook - it also works like that bar the validation.
> >
> >  -Igor
> >
> >
> > On 11/2/05, Phil Kulak <[EMAIL PROTECTED]> wrote:
> > > I know we've talked about this before, but now I need to do it and I
> > > have no clue. The easiest thing, of course, would be to just let the
> > > models get updated, do my validation, and report any errors back to
> > > the user. The problem is that if I let the models get changed, then
> > > Hibernate get's all excited and automatically updates the database at
> > > the end of the request. Has anyone hit this problem before?
> > >
> > >
> > > -------------------------------------------------------
> > > SF.Net email is sponsored by:
> > > Tame your development challenges with Apache's Geronimo App Server.
> > Download
> > > it for free - -and be entered to win a 42" plasma tv or your very own
> > > Sony(tm)PSP.  Click here to play:
> > http://sourceforge.net/geronimo.php
> > > _______________________________________________
> > > Wicket-develop mailing list
> > > [email protected]
> > >
> > https://lists.sourceforge.net/lists/listinfo/wicket-develop
> > >
> >
> >
>
>
> -------------------------------------------------------
> SF.Net email is sponsored by:
> Tame your development challenges with Apache's Geronimo App Server. Download
> it for free - -and be entered to win a 42" plasma tv or your very own
> Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
> _______________________________________________
> Wicket-develop mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/wicket-develop
>


-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
Wicket-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-develop

Reply via email to