H Vineet Thanks for taking the time again to respond. I appreciate every single moment you have sent.
The reason why I add the Phone Number to a list is that, I only want to save those numbers when the user hits the Save Button for the Person as a whole. Lets say a Person X is looked up and loaded into a detail panel/page. As part of his details I display a list of phone numbers he is linked with. When the user hits Add new Phone as part of the person's detail panel, I render a Phone detail panel (via Ajax) yes, and then when user finishes describing the phone number details hits the Done button. OnDone - I simply add it to the List of existing phone numbers which is on the Value Object that is linked to the CPM's Model. When the user finally saves the Person along with the person the phone number's are persisted. Now in relation to James Carman's thoughts, yes I have maintained the Phone Numbers in a separate list and then copy them across to the Persistent Set before I do the Save/Update. The association on the Person entity has a Set<Phone> phones and by Persisting the parent (Person) the encompassing Phones collection can be saved/updated.Hope this is clear with #1 and #2. I cannot save the Phone by itself because it needs a Person object to be persisted.(during a New Person/Phone scenario for example) You are right about using Ajax, so after the Save of the Person, I re-fetch the Person again from backend and re-rendered the Subject and his Phone Numbers List. Certainly it is something how I have done but wanted to give a clearer picture. Thanks to every one for their time and attempt to help. Cheers niv On Fri, Dec 3, 2010 at 5:35 PM, vineet semwal <[email protected]>wrote: > afaik problem is you are doing form.getmodelobject(),that form could be > ajax > submitted and so you are trying to initialize associate > collection in different session.. > > i don't understand your 1. and 2. > why are you adding to list when user has not clicked on save ? > > i think adding a new phone number or entry should itself means a new entry > is persisted and user is shown the new list.. > > > On Fri, Dec 3, 2010 at 2:29 PM, Nivedan Nadaraj <[email protected] > >wrote: > > > Hi > > Yeah so at present, what I do is when the user > > > > 1. Adds a new phone number, I add this to the existing list of > phoneNumbers > > in the UI but yet to be persisted > > 2. User now clicks Save - This saves the Main object ie a Person and > since > > the new phone number is added to the collection while I save Person the > > enclosed associations (phones) also gets persisted > > 3. I now, get the saved Person from backend and re-render the Person > > Information and the list of Phones(including the new one I added) > > 4. All fine so far > > 5. Now when i navigate /intermittently it breaks. > > > > This is response to your > i think better way would be persisting a > user's > > new entry and then showing > > him the actual list which is a reflection of your database.. > > > > Cheers for the thoughts > > Niv > > > > > > On Fri, Dec 3, 2010 at 3:48 PM, vineet semwal < > [email protected] > > >wrote: > > > > > afaik,if your collection is lazy ,you will be able to initialize it in > > the > > > same session .. > > > if you are trying to initialize it in a new/different session you will > > not > > > be able to initialize it.. > > > what i did was making sure that you have a associate collection which > is > > in > > > the same session.. > > > i think better way would be persisting a user's new entry and then > > showing > > > him the actual list which is a reflection of your database.. > > > > > > > > > On Fri, Dec 3, 2010 at 12:50 PM, Nivedan Nadaraj < > [email protected] > > > >wrote: > > > > > > > Vineet > > > > I have not tried that. In this scenario, it will overwrite the > phone's > > > the > > > > user may have added to a list on the UI and is yet to be persisted. > If > > > you > > > > know what I mean. > > > > > > > > 1, Initial fetch of Subject along with his phones ( 5 items) > > > > 2. User adds a new phone number to the subject ( 5 + 1 (yet to be > > > > persisted) > > > > 3. If user navigates and the load() gets a list of Phones for the > > subject > > > > it > > > > will overwrite the ones user has added. > > > > > > > > Not sure if that made sense, thanks for your thoughts > > > > Will ping back > > > > Niv > > > > > > > > > > > > On Thu, Dec 2, 2010 at 5:43 PM, vineet semwal < > > > [email protected] > > > > >wrote: > > > > > > > > > do you see the exception when you try this? > > > > > @Override > > > > > protected Object load() { > > > > > // return > containerForm.getModelObject().getPhoneList(); > > > > > return service.getRequiredObject(*).getPhoneList(); //or any thing > > like > > > > it > > > > > .. > > > > > > > > > > } > > > > > > > > > > On Thu, Dec 2, 2010 at 12:12 PM, Nivedan Nadaraj < > > > [email protected] > > > > > >wrote: > > > > > > > > > > > Hi James > > > > > > > > > > > > Thanks for the time. I use the CPM for the whole use case. > Mmm..is > > > LDM > > > > > > mandatory for such a use case? Am open for thoughts just want the > > > best > > > > > way > > > > > > to implement it. > > > > > > Can you explain a bit further what your thought was please? > > > > > > > > > > > > Thank you > > > > > > Regards > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > On Thu, Dec 2, 2010 at 2:13 PM, James Carman < > > > > [email protected] > > > > > > >wrote: > > > > > > > > > > > > > Just make sure your form's model is a LDM too. > > > > > > > > > > > > > > On Thu, Dec 2, 2010 at 12:23 AM, Nivedan Nadaraj < > > > > > [email protected]> > > > > > > > wrote: > > > > > > > > Hi All > > > > > > > > > > > > > > > > I am guessing this is more of a Hibernate thing/issue but if > > some > > > > one > > > > > > has > > > > > > > > encountered this and has a explanation that I can probably > use > > > from > > > > > the > > > > > > > > Wicket front would be great. > > > > > > > > > > > > > > > > https://forum.hibernate.org/viewtopic.php?f=1&t=1008473 > > > > > > > > > > > > > > > > > > > > > > > > I have a LazyIntializationException when i page through some > > > items. > > > > I > > > > > > use > > > > > > > > the PageableListView, the List item(s) are entities that are > > > > > retrieved > > > > > > > via > > > > > > > > an association Person.phones which is a Set type. > > > > > > > > The funny thing is, the LIException is intermittent. I am > also > > > > using > > > > > > > > OpenSessionInViewFilter. Any thoughts? > > > > > > > > > > > > > > > > By the way the this is the load() implemenation, I have set > the > > > > Model > > > > > > > > Object's phoneList with a list of values fetched via the > > > > > Service->DAO. > > > > > > I > > > > > > > > have used this with other entities without association and it > > > works > > > > > > but > > > > > > > I > > > > > > > > guess is a different scenario(not associations) > > > > > > > > > > > > > > > > Model = new LoadableDetachableModel<Object>() { > > > > > > > > @Override > > > > > > > > protected Object load() { > > > > > > > > return > > > > containerForm.getModelObject().getPhoneList(); > > > > > > > > } > > > > > > > > }; > > > > > > > > } > > > > > > > > > > > > > > > > If someone has any thoughts would appreiciate hearing from > you. > > > > > > > > > > > > > > > > > > > > > > > > Cheers > > > > > > > > > > > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > > > > > > To unsubscribe, e-mail: [email protected] > > > > > > > For additional commands, e-mail: [email protected] > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > -- > > > > > regards, > > > > > Vineet Semwal > > > > > > > > > > > > > > > > > > > > > -- > > > regards, > > > Vineet Semwal > > > > > > > > > -- > regards, > Vineet Semwal >
