[hibernate-issues] [Hibernate-JIRA] Created: (HHH-5163) ClassCastException when Hibernate tries to cache results using ResultTransformer

Strong Liu (JIRA) noreply at atlassian.com
Mon Apr 26 12:37:33 EDT 2010


ClassCastException when Hibernate tries to cache results using ResultTransformer
--------------------------------------------------------------------------------

                 Key: HHH-5163
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5163
             Project: Hibernate Core
          Issue Type: Bug
          Components: core
    Affects Versions: 3.5.1
            Reporter: Strong Liu
            Assignee: Gail Badner
             Fix For: 3.5.x, 3.6


When Hibernate executes a cacheable query using a ResultTransformer, it will attempt to cache the results AFTER applying the ResultTransformer. The problem is that the ResultTransformer may modify the data in a way that Hibernate won't understand it anymore, and in this case it will generate a ClassCastException when trying to cache it.
---------------------------
this can be reproduced by CriteriaQueryTest with following change: 

papa-pc:testsuite stliu$ svn diff src/test/java/org/hibernate/test/criteria/CriteriaQueryTest.java 
Index: src/test/java/org/hibernate/test/criteria/CriteriaQueryTest.java 
=================================================================== 
--- src/test/java/org/hibernate/test/criteria/CriteriaQueryTest.java	(revision 19246) 
+++ src/test/java/org/hibernate/test/criteria/CriteriaQueryTest.java	(working copy) 
@@ -613,6 +613,7 @@ 
 	 ) 
 	 .addOrder( Order.desc("studentName") ) 
 	 .setResultTransformer( Transformers.aliasToBean(StudentDTO.class) ) 
+	 .setCacheable( true ) 
 	 .list(); 
 	
 	 assertEquals(2, resultWithAliasedBean.size()); 


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list