[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-2442) ClassCastException loading from second level cache

Ken Logan (JIRA) noreply at atlassian.com
Wed Jun 13 12:47:04 EDT 2007


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-2442?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_27237 ] 

Ken Logan commented on HHH-2442:
--------------------------------


The cause of this seems to be an unintended dependence on the sort ordering returned from methods such as Class.getDeclaredMethods() and Class.getDeclaredFields().

The order returned by these methods are documented as being arbitrary. However, this order controls the ordering of properties stored in PersistentClass.

I had a reproducible test scenario that was reproducing this problem 100% of the time.  After patching AnnotationBinder.java,v 1.169 so that it sorts the results of these two methods within the addElementsOfAClass() method the problem no longer occurs.

In newer versions of hibernate-annotations, the use of the JDK methods noted above has been moved into implementations of XClass. It appears that the problem still exists.

The fix for this is trivial, just sort the results of the two JDK methods noted above based on something reliable, such as the method/field name.

> ClassCastException loading from second level cache
> --------------------------------------------------
>
>                 Key: HHH-2442
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2442
>             Project: Hibernate3
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 3.2.0.ga, 3.2.1, 3.2.2
>         Environment: Linux 2.6.15-27-686 #1 SMP PREEMPT Fri Dec 8 18:00:07 UTC 2006 i686 GNU/Linux
>            Reporter: Marcio Moraes
>            Priority: Blocker
>
> I'm getting a error when using hibernate 3.2.2.ga with cache (JBoss-Cache) cluster.
> When hibernate get a entity from second level cache it confuses the arrays of values against array of types.
> So in some situations i got ClassCastException ...
> Looking up CacheEntry code at assemble method i saw:
>     private static Object[] assemble(
>             final Serializable[] values,
>             final Object result,
>             final Serializable id,
>             final EntityPersister persister,
>             final Interceptor interceptor,
>             final EventSource session)
>     throws HibernateException {
>         //assembled state gets put in a new array (we read from cache by value!)
>         Object[] assembledProps = TypeFactory.assemble(
>                 values,
>                 persister.getPropertyTypes(),
>                 session, result
>             );
> The issue is values (Serializeble[]) is in wrong order compared with persister.getPropertyTypes() (Type[]).
> If only one cache instance is running it doesnt occurs ...
> I am using Linux.
> Att,
> Márcio Moraes

-- 
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