Uploaded image for project: 'Hibernate ORM'
  1. HHH-10002

Hibernate @Synchronize annotation values should be processed by NamingStrategy

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 5.0.0.Final
    • Fix Version/s: 5.1.0
    • Component/s: hibernate-core
    • Labels:
      None
    • Environment:
      Windows, Java8, Spring Boot
    • Last commented by a user?:
      true
    • Sprint:

      Description

      I had 2 Entities (one was a mapped view)

      @Table(name = "BOOKING_INFO", schema = "BOOKING")
      @Entity
      public class BookingInfo extends AbstractBooking {
      
      @Table(name = "BOOKING_VIEW", schema = "BOOKING")
      @Entity
      @Immutable
      @Synchronize("BOOKING.BOOKING_INFO")
      public class BookingView extends AbstractBooking {
      

      However, a read-operation on BookingView after a write-operation on BookingInfo, did not trigger a flush, so stale data was read.

      When debugging we found that our namingStrategy (SpringNamingStrategy, which extends ImprovedNamingStrategy) lowercases the table name, so we had to put this in the annotatoin:

      @Synchronize("BOOKING.booking_view")
      

      Hibernate should either apply the naming-strategies also to the values from @Synchronize or compare these case-insensitive (which could theoretically lead to too many flushes if you have a crazy database which uses tables with the same name only differentiated by casing).

        Attachments

          Activity

            People

            • Votes:
              3 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - Not Specified
                Not Specified
                Logged:
                Time Spent - 22m
                22m