Uploaded image for project: 'JBoss Enterprise Application Platform 4 and 5'
  1. JBoss Enterprise Application Platform 4 and 5
  2. JBPAPP-5479

HHH-2510 override equals() and fix hashCode() in AliasToBeanResultTransformer

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • EAP_EWP 5.1.1
    • EAP_EWP 5.1.0
    • Hibernate
    • None
    • Release Notes
    • Hide
      AliasToBeanResultTransformer.hashCode relied on propertyAccessor.hashCode(). Implementations of PropertyAccessor do not override hashCode() or equals(). Therefore, Cache lookups involving a QueryKey with an AliasToBeanResultTransformer resulted in a cache miss.

      Two AliasToBeanResultTransformer objects should only be equal and use the same hash code if their resultClass is equal. Getters are determined by aliases, which are provided as an argument, so they are not needed to determine equality. Setters should be used to compute equals() and hashCode(). However, due to the implementations of Setter, Setters do not override hashCode() or equals().

      The fix is to cache the aliases corresponding to the Setters and use that to check for equality. Cache lookups involving a QueryKey with an AliasToBeanResultTransformer no longer result in a cache miss.
      Show
      AliasToBeanResultTransformer.hashCode relied on propertyAccessor.hashCode(). Implementations of PropertyAccessor do not override hashCode() or equals(). Therefore, Cache lookups involving a QueryKey with an AliasToBeanResultTransformer resulted in a cache miss. Two AliasToBeanResultTransformer objects should only be equal and use the same hash code if their resultClass is equal. Getters are determined by aliases, which are provided as an argument, so they are not needed to determine equality. Setters should be used to compute equals() and hashCode(). However, due to the implementations of Setter, Setters do not override hashCode() or equals(). The fix is to cache the aliases corresponding to the Setters and use that to check for equality. Cache lookups involving a QueryKey with an AliasToBeanResultTransformer no longer result in a cache miss.
    • Documented as Resolved Issue

    Description

      AliasToBeanResultTransformer whould override equals()/hashCode() to allow convenient second level query caching.
      Now the only way is to maintain single transformer instance per bean class to allow query cache hit.

      Attachments

        Activity

          People

            shaozliu Strong Liu(刘少壮) (Inactive)
            shaozliu Strong Liu(刘少壮) (Inactive)
            Misty Stanley-Jones Misty Stanley-Jones (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: