Buggy code:
public class FetchConfigurationImpl implements Cloneable , FetchConfiguration { private static final Localizer _loc = Localizer . forPackage ( FetchConfigurationImpl . class ) ; protected static class ConfigurationState implements Serializable { public transient StoreContext ctx = null ; public int fetchBatchSize = 0 ; public int maxFetchDepth = 1 ; public boolean queryCache = true ; public int flushQuery = 0 ; public int lockTimeout = - 1 ; public int readLockLevel = LOCK_NONE ; public int writeLockLevel = LOCK_NONE ; public Set fetchGroups = null ; public Set fields = null ; public Set rootClasses ; public Set rootInstances ; public Map hints = null ; } private final FetchConfigurationImpl . ConfigurationState _state ; private FetchConfigurationImpl _parent ; private String _fromField ; private Class _fromType ; private int _availableRecursion ; private int _availableDepth ; public FetchConfigurationImpl ( ) { } protected FetchConfigurationImpl ( FetchConfigurationImpl . ConfigurationState state ) { } public StoreContext getContext ( ) { } public void setContext ( StoreContext ctx ) { } public Object clone ( ) { } protected FetchConfigurationImpl newInstance ( FetchConfigurationImpl . ConfigurationState state ) { } public void copy ( FetchConfiguration fetch ) { } public int getFetchBatchSize ( ) { } public FetchConfiguration setFetchBatchSize ( int fetchBatchSize ) { } public int getMaxFetchDepth ( ) { } public FetchConfiguration setMaxFetchDepth ( int depth ) { } public boolean getQueryCache ( ) { } public FetchConfiguration setQueryCache ( boolean cache ) { } public int getFlushBeforeQueries ( ) { } public FetchConfiguration setFlushBeforeQueries ( int flush ) { } public Set getFetchGroups ( ) { } public boolean hasFetchGroup ( String group ) { } public FetchConfiguration addFetchGroup ( String name ) { } public FetchConfiguration addFetchGroups ( Collection groups ) { } public FetchConfiguration removeFetchGroup ( String group ) { } public FetchConfiguration removeFetchGroups ( Collection groups ) { } public FetchConfiguration clearFetchGroups ( ) { } public FetchConfiguration resetFetchGroups ( ) { } public Set getFields ( ) { } public boolean hasField ( String field ) { } public FetchConfiguration addField ( String field ) { } public FetchConfiguration addFields ( Collection fields ) { } public FetchConfiguration removeField ( String field ) { } public FetchConfiguration removeFields ( Collection fields ) { } public FetchConfiguration clearFields ( ) { } public int getLockTimeout ( ) { } public FetchConfiguration setLockTimeout ( int timeout ) { } public int getReadLockLevel ( ) { } public FetchConfiguration setReadLockLevel ( int level ) { } public int getWriteLockLevel ( ) { } public FetchConfiguration setWriteLockLevel ( int level ) { } public ResultList newResultList ( ResultObjectProvider rop ) { } private void assertActiveTransaction ( ) { } public void setHint ( String name , Object value ) { } public Object getHint ( String name ) { } public Set getRootClasses ( ) { } public FetchConfiguration setRootClasses ( Collection classes ) { } public Set getRootInstances ( ) { } public FetchConfiguration setRootInstances ( Collection instances ) { } public void lock ( ) { } public void unlock ( ) { } public boolean requiresFetch ( FieldMetaData fm ) { } public FetchConfiguration traverse ( FieldMetaData fm ) { } private boolean includes ( FieldMetaData fmd ) { } private int getAvailableRecursionDepth ( FieldMetaData fm , Class type , boolean traverse ) { int avail = Integer . MIN_VALUE ; for ( FetchConfigurationImpl f = this ; f != null ; f = f . _parent ) { <START_BUG> if ( ImplHelper . isAssignable ( type , f . _fromType ) ) { <END_BUG> avail = f . _availableRecursion ; if ( traverse ) avail = FetchConfigurationImpl . reduce ( avail ) ; break ; } } if ( avail == 0 ) return 0 ; ClassMetaData meta = fm . getDefiningMetaData ( ) ; int max = Integer . MIN_VALUE ; if ( fm . isInDefaultFetchGroup ( ) ) max = meta . getFetchGroup ( NAME_DEFAULT ) . getRecursionDepth ( fm ) ; String [ ] groups = fm . getCustomFetchGroups ( ) ; int cur ; for ( int i = 0 ; ( max != ( FetchGroup . DEPTH_INFINITE ) ) && ( i < ( groups . length ) ) ; i ++ ) { cur = meta . getFetchGroup ( groups [ i ] ) . getRecursionDepth ( fm ) ; if ( ( cur == ( FetchGroup . DEPTH_INFINITE ) ) || ( cur > max ) ) max = cur ; } if ( ( traverse && ( max != ( Integer . MIN_VALUE ) ) ) && ( ImplHelper . isAssignable ( meta . getDescribedType ( ) , type ) ) ) max = FetchConfigurationImpl . reduce ( max ) ; if ( ( avail == ( Integer . MIN_VALUE ) ) && ( max == ( Integer . MIN_VALUE ) ) ) { int def = FetchGroup . RECURSION_DEPTH_DEFAULT ; return traverse && ( ImplHelper . isAssignable ( meta . getDescribedType ( ) , type ) ) ? def - 1 : def ; } if ( ( avail == ( Integer . MIN_VALUE ) ) || ( avail == ( FetchGroup . DEPTH_INFINITE ) ) ) return max ; if ( ( max == ( Integer . MIN_VALUE ) ) || ( max == ( FetchGroup . DEPTH_INFINITE ) ) ) return avail ; return Math . min ( max , avail ) ; } private static Class getRelationType ( FieldMetaData fm ) { } private static int reduce ( int d ) { } FetchConfiguration getParent ( ) { } boolean isRoot ( ) { } FetchConfiguration getRoot ( ) { } int getAvailableFetchDepth ( ) { } int getAvailableRecursionDepth ( ) { } String getTraversedFromField ( ) { } Class getTraversedFromType ( ) { } List getPath ( ) { } List trackPath ( List path ) { } public String toString ( ) { } private String getPathString ( ) { } }

Fix:
if ( ImplHelper . isAssignable ( f . _fromType , type ) ) {