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

HHH-5163 Bug when applying a ResultTransformer on a cacheable projection based criteria

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: EAP 5.0.0.CR5, EAP 5.0.1.CR2, EAP 5.0.1, EAP_EWP 5.1.0
    • Fix Version/s: EAP_EWP 5.1.1
    • Component/s: Hibernate
    • Labels:
      None
    • Affects:
      Release Notes
    • Release Notes Text:
      Hide
      When Hibernate executed a cacheable query using a <classname>ResultTransformer</classname>, it attempted to cache the results after applying the <classname>ResultTransformer</classname>. However, the data might be modified so that Hibernate could not read it. In this case, a <exceptionname>ClassCastException</exceptionname> would occur when attempting to cache the results.

      This issue is fixed by introducing three new classes to the API:
      org.hibernate.transform.AliasedTupleSubsetResultTransformer
      org.hibernate.transform.CacheableResultTransformer
      org.hibernate.transform.TupleSubsetResultTransformer

      Review the Javadoc for Hibernate for more details.
      Show
      When Hibernate executed a cacheable query using a <classname>ResultTransformer</classname>, it attempted to cache the results after applying the <classname>ResultTransformer</classname>. However, the data might be modified so that Hibernate could not read it. In this case, a <exceptionname>ClassCastException</exceptionname> would occur when attempting to cache the results. This issue is fixed by introducing three new classes to the API: org.hibernate.transform.AliasedTupleSubsetResultTransformer org.hibernate.transform.CacheableResultTransformer org.hibernate.transform.TupleSubsetResultTransformer Review the Javadoc for Hibernate for more details.
    • Release Notes Docs Status:
      Documented as Resolved Issue

      Description

      Typically following code will raise a CCE
      Criteria crit = session.createCriteria(MyEntity.class);
      crit.setProjection( Projections.projectionList()
      .add( Projections.alias(Projections.property("description"), "description" ))
      .add( Projections.alias(Projections.property("id"), "id" ))
      );
      crit.setCacheable(true);
      crit.setResultTransformer(Transformers.aliasToBean(MyEntity.class));
      List results = crit.list();

      java.lang.ClassCastException: org.hibernate.test.case756453.MyEntity
      at org.hibernate.cache.StandardQueryCache.put(StandardQueryCache.java:106)
      at org.hibernate.loader.Loader.putResultInQueryCache(Loader.java:2208)
      at org.hibernate.loader.Loader.listUsingQueryCache(Loader.java:2159)
      at org.hibernate.loader.Loader.list(Loader.java:2117)
      at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:118)
      at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1596)
      at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:306)

      There is a problem between the real cached value and the expected cached value (maybe the transformer is applied too soon or query cache is not aware the cached value is already transformed,...).

      http://opensource.atlassian.com/projects/hibernate/browse/HHH-5163

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

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

                  Dates

                  • Created:
                    Updated:
                    Resolved: