Firstly, that LDM code is broken - calling detach() on load() makes no sense.

Also, it will hit hibernate on every call to getObject(), as you aren't caching 
the loaded Parent entity. This is probably the cause of the hibernate 
exceptions you are seeing.

Check out http://wicketinaction.com/2008/09/building-a-smart-entitymodel/ for a 
solid persistence backed LDM implementation.

Unrelated, your ParentsService.load() method probably doesn't need to take the 
entity class a parameter - the service should know the entity type it is 
querying hibernate for.

----- Original Message -----
From: "lucast" <lucastol...@hotmail.com>
To: users@wicket.apache.org
Sent: Wednesday, 13 April, 2011 7:20:15 PM
Subject: Re: Refreshing loadable detachable model object inside an ajax call

Hi Clint, thanks for your email.

After reading your post, this is how I've implemented the LDM class:


public class LoadableParentModel extends LoadableDetachableModel {

        Long id;

        public LoadableParentModel(Long id){

                this.id = id;

        }

        @Override       protected Parent load() {

                Parent Parent =
WicketApplication.get().getParents_service().load(Parent.class, id);

                detach();

                return Parent;

        }

}




Is that what you mean by explicitly calling .detach() on the LDM?

I apologise if I didn't get that right straight away. I have implemented it
as in the above example but when I call (Parent) model.getObject(); I get
the same exception as before.

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Refreshing-loadable-detachable-model-object-inside-an-ajax-call-tp3446979p3447904.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
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

Reply via email to