David, Thanks for the feedback. At first I thought the formula hibernate feature was very handy, but now that I'm seeing the drawbacks to it, I think I'm going to dump it. I think I'll add the actual jdbc logic to getCountReports, getAvgQuestion1, etc. In the long run, that should be easier to maintain.
Tauren On 7/11/07, David Bernard <[EMAIL PROTECTED]> wrote: > IMHO, because data are not managed (calculated/updated) by your application, > you could : > * refresh Service from RDBMS when reports are submitted, but in this case > you forgot unsaved modification into Service (maybe you could do a partial > refresh if you extract computed property into an > encapsulated object (with it's own cache rule) > * or don't use formula, and do a direct JDBC query into getCoutnReports() > and getAvgQuestions1(). > > Regards > > Tauren Mills wrote: > > I'm working on a site that allows people to rate services. There is a > > Services entity that contains a set of Report entities. Users can add > > new services and submit reports on those services. The reports have > > questions that users rate from 1 to 5 stars. > > > > I am using hibernate properties with formulas to calculate several > > things. Doing this has really simplified things, however it looks > > like it may have made other things more complex. For instance, I have > > properties like this in Service: > > > > <property name="avgQuestion1" > > formula="(select round(avg(r.question1)) from report r where > > r.service_id = service_id)" /> > > <property name="countReports" > > formula="(select count(*) from report r where r.service_id = > > service_id)" /> > > > > The users see a dataview of services. One of the columns is the number > > of reports submitted for that service. The problem is that when the > > user submits a report and then goes back to the dataview, the list > > isn't updated to indicate the new report. The value of countReports > > is still the same. Nor are the averages updated. > > > > The Services table hasn't changed when a report is submitted, so > > hibernate isn't refreshing. However, the calculated formulas HAVE > > changed, but aren't causing the data to be re-read. > > > > Are there recommended ways to force a refresh of the data? Should I > > do it in the dataview? Or should I do it when a new report is > > submitted? Any suggestions and advice is much appreciated! > > > > Tauren > > > > ------------------------------------------------------------------------- > > 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 > > Wicket-user@lists.sourceforge.net > > 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 > Wicket-user@lists.sourceforge.net > 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 Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user