[hibernate-issues] [Hibernate-JIRA] Created: (HHH-2437) SessionFactoryImpl.getClassMetadata method is not supported CGLib enhanced classes

Alexey Kakunin (JIRA) noreply at atlassian.com
Wed Feb 21 10:19:31 EST 2007


SessionFactoryImpl.getClassMetadata method is not supported CGLib enhanced classes
----------------------------------------------------------------------------------

         Key: HHH-2437
         URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2437
     Project: Hibernate3
        Type: Bug

  Components: core  
    Versions: 3.2.1, 3.2.2    
    Reporter: Alexey Kakunin


In some cases Hibernate may returns classes, enhanced by CGLib. But if then we will try to get Class MetaData for such classes - it will be failed. For example:

Object obj = getObjectFrom Hibernate(); //here CGLib enhanced object is returned
ClassMetaData metaData = sessionFactory.getClassMetaData(obj.getClass());

//even we just get class from hibernate and it's class supported by Hibernate - we will get here NULL.

Simple Solution is to check before getting name from class:

	public ClassMetadata getClassMetadata(Class persistentClass) throws HibernateException {
                Class fixedClass = persistentClass;
		if (net.sf.cglib.proxy.Enhancer.isEnhanced(persistentClass)) {
			// try to get class itself
			fixedClass = valueClass.getSuperclass();
		}

		return getClassMetadata( fixedClass.getName() );
	}

but not sure it is really correct fix

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