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

Reply via email to