Re: [Wicket-user] LoadableDetachableModel in form processing
Happy NewYear! On 2/25/07, Matthew Kwong [EMAIL PROTECTED] wrote: Sorry guys, I was in Chinese new year vacation and out of the town without any internet connection. Anyway, Iman is right, it is the model in palette that's causing this exception. Thank you so much :) Matthew Iman Rahmatizadeh wrote: 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));
Re: [Wicket-user] LoadableDetachableModel in form processing
Sorry guys, I was in Chinese new year vacation and out of the town without any internet connection. Anyway, Iman is right, it is the model in palette that's causing this exception. Thank you so much :) Matthew Iman Rahmatizadeh wrote: 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
Re: [Wicket-user] LoadableDetachableModel in form processing
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=lnkkid=120709bid=263057dat=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.phpp=sourceforgeCID=DEVDEV
Re: [Wicket-user] LoadableDetachableModel in form processing
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 --
Re: [Wicket-user] LoadableDetachableModel in form processing
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 avoid 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=lnkkid=120709bid=263057dat=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.phpp=sourceforgeCID=DEVDEV ___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user
Re: [Wicket-user] LoadableDetachableModel in form processing
I should clarify that last paragraph: I don't know Wicket well enough to be sure you haven't found a bug and of course I don't know your code. I've just run into this often enough in Hibernate to make an educated guess. Let us know how it works out. -Ryan On Feb 18, 2007, at 2:08 AM, Ryan Holmes 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 avoid 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=lnkkid=120709bid=263057dat=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.phpp=sourceforgeCID=DEVDEV ___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user
Re: [Wicket-user] LoadableDetachableModel in form processing
Basically, while it is great that you can work directly with hibernate objects in Wicket components, there are a couple of dangers to it as well. Especially when you use with a filter that opens and closes a transaction on every (Wicket) request and/or you have implicit transactions turned on, you can be in for nasty surprises (like this one). I'm not in favor of such an approach personally, though I can understand people who use it because it saves time and make for a very easy programming model. Alternatively, you can make sure that you put any hibernate access behind dao/ service interfaces and limit transactions to those interfaces. Basically you can use a layer of services which uses a layer of daos and use the services to group access to daos and define the transaction on (e.g. using Spring's @Transaction annotation). Going one step further, you might even consider not using hibernate objects outside those service methods at all, but instead use value objects. I don't believe that's necessary, but if you do that, you'll never ever will be in trouble. My 2c, Eelco On 2/18/07, Ryan Holmes [EMAIL PROTECTED] wrote: I should clarify that last paragraph: I don't know Wicket well enough to be sure you haven't found a bug and of course I don't know your code. I've just run into this often enough in Hibernate to make an educated guess. Let us know how it works out. -Ryan On Feb 18, 2007, at 2:08 AM, Ryan Holmes 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 avoid 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/
Re: [Wicket-user] LoadableDetachableModel in form processing
Hi, 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] I don't think this error is related to Wicket models or components. Did you make any progress on this in the mean time? Eelco - 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.phpp=sourceforgeCID=DEVDEV ___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user
[Wicket-user] LoadableDetachableModel in form processing
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=lnkkid=120709bid=263057dat=121642 ___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user