• Post Reply Bookmark Topic Watch Topic
  • New Topic

Seam EntityHome update parent problem  RSS feed

 
Mark Varley
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all - I have a Seam application with the following entity relationship modelled: Vendor one-to-many Booking one-to-one BookingReview. Once a customer has completed a booking they get sent an email inviting them to review their booking experience, they sign in, access a list of bookings (modelled as an EntityQuery) and if the booking has no review they can add one - this takes them to a standard BookingReviewEdit screen as per the seam-gen generated screens.

On persist of the BookingReview I want to run a method on the Vendor to refresh the average ratings for that Vendor (these are calculated and stored in the vendor table for performance reasons). I use the following code in my BookingReviewHome class:



The problem is that the average ratings are not being populated. I put a breakpoint in calculateAverageRating() it seems that at the point this is being run, as it iterates over the list of bookings it does not find the review I just added. I checked the log at this point and can see the SQL to insert the review however this has not yet been flushed to the database.

I have tried to add a getEntityManager().flush() statement just after super.persist() but this makes no difference. I have also tried to set flush-mode="AUTO" in BookingReview.page.xml but again, no luck, calculateAveRating() still does not find my review. I have also tried a different approach entirely putting the following in my VendorHome class:



Again, this does not work.

If anyone can suggest where I am going wrong or a better way of achieving my desired result I would be most grateful as I have spent a huge amount of time on this seemingly trivial problem. For completeness I have included extracts from my entity classes below showing the relationship between my entities.

Thanks in advance,

mark

Vendor:



Booking:



BookingReview:




 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!