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

    • Affects:
      Release Notes
    • Release Notes Text:
      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.
    • Release Notes Docs Status:
      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.

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                stliu Strong Liu
                Reporter:
                stliu Strong Liu
                Writer:
                Misty Stanley-Jones
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: