BTW, we did this on my last project and hibernate was not a limiting factor.
regards Nino Wilko Hische wrote: > Hi Dimitrio, > > You may want to have a look at this reply (and thread): > > http://www.nabble.com/Wicket---Hibernate---Application-Transactions-tf1947542.html#a5349464 > > In short, it *does* recommend reloading your city as well per request (in > combination with a second level cache). The performance hit might be less > then you would expect and the pattern obviously is much simpler. > > Best regards, > > Wilko Hische > > > Dimitrio wrote: > >> Hello, Nino. >> >> Thanks for a quick reply! >> >> I think clearing the Hibernate session cache (via Session.clear()) before >> saving the city will work for me in this case. >> >> However the second concern remains. Consider a complex form with tens of >> drop down choice or list components. I want them loaded once (during the >> rendering phase) or reloaded upon page refresh (when the user refreshes a >> page, they expect to see fresh reference data). During submit I would try >> to >> avoid sucking in all that data from the database again. >> >> I wonder if there is a solution to that or maybe some "Wicket design >> pattern" to approach such situations. >> >> Best regards, >> Dimitrio >> >> On 5/9/07, Nino Saturnino Martinez Vazquez Wael <[EMAIL PROTECTED]> >> wrote: >> >>> Hi Dimitrio >>> >>> The solution(possibly) to your first problem are to call flush on your >>> hibernate session. Altthough im far from a hibernate expert, this solved >>> our problems with that kind of exception. You could also try merge(), im >>> afraid im just guessing at this point. >>> >>> regards Nino >>> >>> Dimitrio wrote: >>> >>>> Hello All, >>>> >>>> I am evaluating the possibility to use the Wicket / Spring / Hibernate >>>> stack for my next project (Spring / Hibernate being used for the >>>> middle tier + OpenSessionInViewFilter). >>>> >>>> Let me describe a simple test scenario that I am trying to implement - >>>> a City Editor panel. The panel contains a text field with a city name >>>> and a drop down choice with the available countries. >>>> >>>> The domain model (mapped to the DB via Hibernate) is the following: >>>> >>>> City >>>> --------- >>>> Long id; >>>> String name; >>>> >>>> @Cascade(SAVE_UPDATE) >>>> Country country; >>>> >>>> Country >>>> ------------ >>>> Long id; >>>> String isoCode; >>>> String name; >>>> >>>> Upon construction, the Country drop down choice for the panel is >>>> provided with a LoadableDetachableModel that loads a list of all >>>> available countries from a CountryDao. The form itself has a >>>> CompoundPropertyModel for the city being edited. >>>> >>>> The page renders just fine, the country list is correctly reloaded >>>> upon F5 - everything as expected. >>>> >>>> However, when the user clicks Submit, the form component reloads the >>>> country list again (so the list ends up in the new Hibernate session >>>> cache) and when I try to save the city in onSubmit, I sometimes get a >>>> Hibernate exception with the following message: >>>> >>>> a different object with the same identifier value was already >>>> associated with the session: [test.wicket.Country#6]; nested exception >>>> is org.hibernate.NonUniqueObjectException: a different object with the >>>> same identifier value was already associated with the session: >>>> [test.wicket.Country#6] >>>> >>>> This exception only occurs if the user does not change the city's >>>> country. In that case the Country instance referenced by the city is >>>> different from the corresponding instance in Hibernate session cache >>>> and the SAVE_UPDATE cascading fails. >>>> >>>> So, my first question is whether there is a way to avoid this >>>> >>> exception? >>> >>>> The second thing is that I do not generally want all my reference data >>>> being completely reloaded on every submit. >>>> >>>> I really liked the way property editors were used in Spring to >>>> retrieve and validate reference data for such scenarios. In Spring I >>>> would have a CountryPropertyEditor that would retrieve the Country >>>> instance by an ISO code or ID and assign it to the city. >>>> >>>> So in Spring the submit would result in 2 statements like below: >>>> >>>> select from country where id=... >>>> update city where id=... >>>> >>>> and avoid the duplicate instances problem altogether. >>>> >>>> So, the second question is whether there is a way to not reload all >>>> the reference data upon submit? How do you address such scenarios in >>>> your Wicket applications? >>>> >>>> >>>> Many thanks! >>>> >>>> --Dimitrio >>>> >>>> >>>> >>>> >>> ------------------------------------------------------------------------ >>> >>>> >>> ------------------------------------------------------------------------- >>> >>>> This SF.net email is sponsored by DB2 Express >>>> Download DB2 Express C - the FREE version of DB2 express and take >>>> control of your XML. No limits. Just data. Click to get it now. >>>> http://sourceforge.net/powerbar/db2/ >>>> >>>> >>> ------------------------------------------------------------------------ >>> >>>> _______________________________________________ >>>> Wicket-user mailing list >>>> [email protected] >>>> https://lists.sourceforge.net/lists/listinfo/wicket-user >>>> >>>> >>> ------------------------------------------------------------------------- >>> This SF.net email is sponsored by DB2 Express >>> Download DB2 Express C - the FREE version of DB2 express and take >>> control of your XML. No limits. Just data. Click to get it now. >>> http://sourceforge.net/powerbar/db2/ >>> _______________________________________________ >>> Wicket-user mailing list >>> [email protected] >>> https://lists.sourceforge.net/lists/listinfo/wicket-user >>> >>> >> ------------------------------------------------------------------------- >> This SF.net email is sponsored by DB2 Express >> Download DB2 Express C - the FREE version of DB2 express and take >> control of your XML. No limits. Just data. Click to get it now. >> http://sourceforge.net/powerbar/db2/ >> _______________________________________________ >> Wicket-user mailing list >> [email protected] >> https://lists.sourceforge.net/lists/listinfo/wicket-user >> >> >> > > ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Wicket-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/wicket-user
