Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Seam EntityHome update parent problem

Mark Varley
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 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,





Water! People swim in water! Even tiny ads swim in water:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!