Matthew, the line where you create a palette object, I see you're using
Model instead of a Loadable model, what does the getDataStoreRoles() do ?
Does it load the DataStoreUser object ? Models are normally dangerous to use
with persistent objects, as they usually hold on to the instance during
sessions instead of loading them again. Maybe that's causing the
DataStoreUser object to live outside the previous session and cause the
problem. Replace the Model with a LoadableDetachableModel and see if the
problem goes away.
And karthik, I create and release the hibernate session in the request
cycle, which is just some variant of OpenSessionInViewFilter pattern, and
haven't had any problems with it. You just have to remember to always get
the object from the underlying model, and pass around the model. However the
only problem is the code gets really ugly with all the casts and getObject()
methods. I cant wait to move on to wicket 2.0 !

Iman

On 2/19/07, karthik Guru <[EMAIL PROTECTED]> wrote:


Personally I have have run into lot of issues with OpenSessionInViewFilter
pattern, so much so that I decided to take it off - At least the app now
works as 'I expect'.
But then am not an hibernate expert.

>> The standard solution is to use Session.merge()

Doesn't merge recreate the entity if its say deleted by another
user-session?. May be one can do a load before doing a merge just to make
sure that the entry actually exists in the DB  at that point in time.



On 2/18/07, Ryan Holmes <[EMAIL PROTECTED]> wrote:
>
> org.hibernate.NonUniqueObjectException is a really common problem. My
> guess is that the DataStoreUser is being loaded once to pass it into
> the page constructor and again by the LoadableDetachableModel within
> the same Hibernate session. Same persistent object loaded into two
> separate instance variables in the same (Hibernate) session -- boom,
> NonUniqueObjectException.
>
> There are a couple of ways to fix this. The "correct" solution is to
> avd'oid loading the object more than once in the first place. For
> instance, maybe you could take a user id instead of a user object
> into your page constructor to remove one of the load operations. The
> standard solution is to use Session.merge() instead of, say,
> Session.saveOrUpdate () (I assume you're getting this exception when
> the Hibernate session flushes).
>
> In any event, this is happening because LoadableDetachableModel is
> working as intended and thereby revealing one of Hibernate's many
> "quirks" -- not because of a problem in Wicket.
>
>
> -Ryan
> On Feb 10, 2007, at 2:31 AM, Matthew Kwong wrote:
>
> >
> > Hi fellows,
> >
> > Last time I asked how to use chain in CompoundPropertyModel with
> > LoadableDetachableModel, it worked since my page has no form (no
> > submit).
> > This time, I make another page and try to use the chain again, and
> > hibernate
> > throws org.hibernate.NonUniqueObjectException when I submit the form.
> >
> > Caused by: org.hibernate.NonUniqueObjectException: a different
> > object with
> > the same identifier value was already associated with the session:
> > [datastore2.model.DataStoreRole#1 ]
> >
> > My Panel:
> >
> > public UserDetail(String id, DataStoreUser user, final Panel
> > prevPanel) {
> >         super(id);
> >         add(new FeedbackPanel("feedback"));
> >
> >         add(new Link("back") {
> >             public void onClick() {
> >                 getParent().replaceWith(prevPanel);
> >             }
> >         });
> >
> >         Form form = new Form("form") {
> >             protected void onSubmit() {
> >                 DataStoreUser user = (DataStoreUser)
> > this.getModelObject();
> >                 try {
> >                     getDelegate().saveUser(user);
> >                     info("You have saved the user profile: " +
> > user.getFullname() + ".");
> >                 } catch (Exception e) {
> >                     e.printStackTrace();
> >                     error("Your user profile state is stale
> > (someone has
> > updated the same user profile while you are on this page). Please
> > press BACK
> > and come back.");
> >                 }
> >             }
> >         };
> >
> >         form.setModel(new CompoundPropertyModel(new
> > LoadableDataStoreUserModel(getDelegate().getDataStoreUser(user.getId
> > ()))));
> >         form.add(new Label("id"));
> >         form.add(new Label("username"));
> >         form.add(new RequiredTextField("firstname"));
> >         form.add(new
> > TextField("lastname").setConvertEmptyInputStringToNull(false));
> >         form.add(new Label("email"));
> >         form.add(new Palette("roles", new
> > Model((Serializable)getDelegate().getDataStoreRoles()), new
> > RoleChoiceRenderer(), 10, true));
> >         add(form);
> >     }
> >
> > Is LoadableDetachableModel working for form processing? Because it is
> > working if I only have
> > form.setModel(new
> > CompoundPropertyModel(getDelegate().getDataStoreUser( user.getId())));
> >
> > The reason why i want this loadable since I want to update the page
> > with
> > "F5" refresh button again if someone has changed the same user in
> > another
> > computer.
> >
> > Thank you :)
> > Matthew Kwong
> > --
> > View this message in context: http://www.nabble.com/
> > LoadableDetachableModel-in-form-processing-tf3204839.html#a8899449
> > Sent from the Wicket - User mailing list archive at Nabble.com.
> >
> >
> > ----------------------------------------------------------------------
> > ---
> > Using Tomcat but need to do more? Need to support web services,
> > security?
> > Get stuff done quickly with pre-integrated technology to make your
> > job easier.
> > Download IBM WebSphere Application Server v.1.0.1 based on Apache
> > Geronimo
> > http://sel.as-us.falkag.net/sel?
> > cmd=lnk&kid=120709&bid=263057&dat=121642
> > _______________________________________________
> > Wicket-user mailing list
> > Wicket-user@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/wicket-user
>
>
> -------------------------------------------------------------------------
>
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share
> your
> opinions on IT & business topics through brief surveys-and earn cash
>
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> Wicket-user mailing list
> Wicket-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/wicket-user
>



--
-- karthik --
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share
your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to