From: <hib...@li...> - 2006-05-10 13:22:19
|
Author: max...@jb... Date: 2006-05-10 09:22:15 -0400 (Wed, 10 May 2006) New Revision: 9920 Modified: trunk/Hibernate3/src/org/hibernate/property/DirectPropertyAccessor.java Log: tell the user what we are actually complaining about. Modified: trunk/Hibernate3/src/org/hibernate/property/DirectPropertyAccessor.java =================================================================== --- trunk/Hibernate3/src/org/hibernate/property/DirectPropertyAccessor.java 2006-05-10 05:40:41 UTC (rev 9919) +++ trunk/Hibernate3/src/org/hibernate/property/DirectPropertyAccessor.java 2006-05-10 13:22:15 UTC (rev 9920) @@ -94,19 +94,34 @@ private static Field getField(Class clazz, String name) throws PropertyNotFoundException { if ( clazz==null || clazz==Object.class ) { - throw new PropertyNotFoundException("field not found: " + name); // TODO: we should report what class we started searching for the property - right now it will always end on Object.class. + throw new PropertyNotFoundException("field not found: " + name); } Field field; try { field = clazz.getDeclaredField(name); } catch (NoSuchFieldException nsfe) { - field = getField( clazz.getSuperclass(), name ); + field = getField( clazz, clazz.getSuperclass(), name ); } if ( !ReflectHelper.isPublic(clazz, field) ) field.setAccessible(true); return field; } + private static Field getField(Class root, Class clazz, String name) throws PropertyNotFoundException { + if ( clazz==null || clazz==Object.class ) { + throw new PropertyNotFoundException("field [" + name + "] not found on " + root.getName()); + } + Field field; + try { + field = clazz.getDeclaredField(name); + } + catch (NoSuchFieldException nsfe) { + field = getField( root, clazz.getSuperclass(), name ); + } + if ( !ReflectHelper.isPublic(clazz, field) ) field.setAccessible(true); + return field; + } + public Getter getGetter(Class theClass, String propertyName) throws PropertyNotFoundException { return new DirectGetter( getField(theClass, propertyName), theClass, propertyName ); |