Buggy code:
public class QueryKey implements Externalizable { private static Collection s_unmod = new HashSet ( ) ; private String _candidateClassName ; private boolean _subclasses ; private Set _accessPathClassNames ; private String _query ; private boolean _ignoreChanges ; private Map _params ; private long _rangeStart ; private long _rangeEnd ; private int _timeout = - 1 ; public static QueryKey newInstance ( Query q ) { } public static QueryKey newInstance ( Query q , Object [ ] args ) { } public static QueryKey newInstance ( Query q , Map args ) { } static QueryKey newInstance ( QueryContext q , boolean packed , Object [ ] args , Class candidate , boolean subs , long startIdx , long endIdx ) { } static QueryKey newInstance ( QueryContext q , boolean packed , Map args , Class candidate , boolean subs , long startIdx , long endIdx ) { } private static QueryKey createKey ( QueryContext q , boolean packed , Class candidateClass , boolean subclasses , long startIdx , long endIdx ) { if ( candidateClass == null ) return null ; if ( ( q . getCandidateCollection ( ) ) != null ) return null ; if ( ( ( q . getResultType ( ) ) != null ) && packed ) return null ; Class [ ] types = q . getProjectionTypes ( ) ; for ( int i = 0 ; i < ( types . length ) ; i ++ ) { switch ( JavaTypes . getTypeCode ( types [ i ] ) ) { case JavaTypes . ARRAY : return null ; case JavaTypes . COLLECTION : case JavaTypes . MAP : case JavaTypes . OBJECT : if ( ! ( ImplHelper . isManagedType ( types [ i ] ) ) ) return null ; break ; } } ClassMetaData [ ] metas = q . getAccessPathMetaDatas ( ) ; if ( ( metas . length ) == 0 ) return null ; Set accessPathClassNames = new HashSet ( ( ( int ) ( ( ( metas . length ) * 1.33 ) + 1 ) ) ) ; ClassMetaData meta ; for ( int i = 0 ; i < ( metas . length ) ; i ++ ) { meta = metas [ i ] ; while ( ( meta . getPCSuperclass ( ) ) != null ) meta = meta . getPCSuperclassMetaData ( ) ; if ( ( meta . getDataCache ( ) ) == null ) return null ; accessPathClassNames . add ( meta . getDescribedType ( ) . getName ( ) ) ; } StoreContext ctx = q . getStoreContext ( ) ; if ( ( ( QueryKey . intersects ( accessPathClassNames , ctx . getPersistedTypes ( ) ) ) || ( QueryKey . intersects ( accessPathClassNames , ctx . getUpdatedTypes ( ) ) ) ) || ( QueryKey . intersects ( accessPathClassNames , ctx . getDeletedTypes ( ) ) ) ) return null ; <START_BUG> MetaDataRepository repos = ctx . getConfiguration ( ) . getMetaDataRepository ( ) ; <END_BUG> if ( candidateClass . isInterface ( ) ) return null ; meta = repos . getMetaData ( candidateClass , ctx . getClassLoader ( ) , true ) ; int timeout = meta . getDataCacheTimeout ( ) ; if ( subclasses ) { metas = meta . getPCSubclassMetaDatas ( ) ; int subTimeout ; for ( int i = 0 ; i < ( metas . length ) ; i ++ ) { if ( ( metas [ i ] . getDataCache ( ) ) == null ) return null ; subTimeout = metas [ i ] . getDataCacheTimeout ( ) ; if ( ( subTimeout != ( - 1 ) ) && ( subTimeout < timeout ) ) timeout = subTimeout ; } } QueryKey key = new QueryKey ( ) ; key . _candidateClassName = candidateClass . getName ( ) ; key . _subclasses = subclasses ; key . _accessPathClassNames = accessPathClassNames ; key . _timeout = timeout ; key . _query = q . getQueryString ( ) ; key . _ignoreChanges = q . getIgnoreChanges ( ) ; key . _rangeStart = startIdx ; key . _rangeEnd = endIdx ; return key ; } private static boolean setParams ( QueryKey key , QueryContext q , Object [ ] args ) { } private static boolean setParams ( QueryKey key , StoreContext ctx , Map params ) { } public QueryKey ( ) { } public String getCandidateTypeName ( ) { } public int getTimeout ( ) { } public boolean changeInvalidatesQuery ( Collection changed ) { } private static boolean intersects ( Collection names , Collection changed ) { } public boolean equals ( Object ob ) { } public int hashCode ( ) { } public String toString ( ) { } public void writeExternal ( ObjectOutput out ) throws IOException { } public void readExternal ( ObjectInput in ) throws IOException , ClassNotFoundException { } }

Fix:
MetaDataRepository repos = ctx . getConfiguration ( ) . getMetaDataRepositoryInstance ( ) ;