Buggy code:
protected boolean isMappingMode ( ) { } protected boolean isMappingOverrideMode ( ) { } public void clear ( ) { } public void parse ( Class cls ) { } private void updateSourceMode ( ClassMetaData meta ) { } private void parsePackageAnnotations ( ) { } protected void parsePackageMappingAnnotations ( Package pkg ) { } protected boolean handleUnknownPackageAnnotation ( Package pkg , Annotation anno ) { } private int getSourceMode ( Package pkg ) { } private void addSourceMode ( Package pkg , int mode ) { } private ClassMetaData parseClassAnnotations ( ) { } protected void parseClassMappingAnnotations ( ClassMetaData meta ) { } protected boolean handleUnknownClassAnnotation ( ClassMetaData meta , Annotation anno ) { } private ClassMetaData getMetaData ( ) { } protected File getSourceFile ( ) { } private void parseDataStoreId ( ClassMetaData meta , DataStoreId id ) { } private void warnFlushMode ( Object context ) { } private void parseDataCache ( ClassMetaData meta , DataCache cache ) { } private void parseDetachedState ( ClassMetaData meta , DetachedState detached ) { } private Collection < LifecycleCallbacks > [ ] parseEntityListeners ( ClassMetaData meta , EntityListeners listeners ) { } public static Collection < LifecycleCallbacks > [ ] parseCallbackMethods ( Class cls , Collection < LifecycleCallbacks > [ ] callbacks , boolean sups , boolean listener , MetaDataRepository repos ) { } private void recordCallbacks ( ClassMetaData cls , Collection < LifecycleCallbacks > [ ] callbacks , int [ ] highs , boolean superClass ) { } private void parseFetchGroups ( ClassMetaData meta , FetchGroup ... groups ) { } private void parseFetchAttribute ( ClassMetaData meta , org . apache . openjpa . meta . FetchGroup fg , FetchAttribute attr ) { } private void parseMemberAnnotations ( FieldMetaData fmd ) { } protected void parseMemberMappingAnnotations ( FieldMetaData fmd ) { } protected boolean handleUnknownMemberAnnotation ( FieldMetaData fmd , Annotation anno ) { } private static Class toOverrideType ( Class cls ) { } private void parseReadOnly ( FieldMetaData fmd , ReadOnly ro ) { } private void parseGeneratedValue ( FieldMetaData fmd , GeneratedValue gen ) { } static void parseGeneratedValue ( FieldMetaData fmd , GenerationType strategy , String generator ) { } private static int getGeneratedValueStrategy ( Object context , GenerationType strategy , String generator ) { } private void parseBasic ( FieldMetaData fmd , Basic anno , boolean lob ) { } private void parseManyToOne ( FieldMetaData fmd , ManyToOne anno ) { } private void parseOneToOne ( FieldMetaData fmd , OneToOne anno ) { } private void parseEmbedded ( FieldMetaData fmd , Embedded anno ) { } private void parseOneToMany ( FieldMetaData fmd , OneToMany anno ) { } private void parseManyToMany ( FieldMetaData fmd , ManyToMany anno ) { } private void parseMapKey ( FieldMetaData fmd , MapKey anno ) { } protected void parseLobMapping ( FieldMetaData fmd ) { } private void parseOrderBy ( FieldMetaData fmd , OrderBy anno ) { } private void parsePersistent ( FieldMetaData fmd , Persistent anno ) { } private void parsePersistentCollection ( FieldMetaData fmd , PersistentCollection anno ) { } private void parsePersistentMap ( FieldMetaData fmd , PersistentMap anno ) { } private void setCascades ( ValueMetaData vmd , CascadeType [ ] cascades ) { } private void parseSequenceGenerator ( AnnotatedElement el , SequenceGenerator gen ) { } private void parseNamedQueries ( AnnotatedElement el , NamedQuery ... queries ) { } private void parseNamedNativeQueries ( AnnotatedElement el , NamedNativeQuery ... queries ) { QueryMetaData meta ; for ( NamedNativeQuery query : queries ) { if ( StringUtils . isEmpty ( query . name ( ) ) ) throw new org . apache . openjpa . util . MetaDataException ( AnnotationPersistenceMetaDataParser . _loc . get ( "no-native-query-name" , el ) ) ; if ( StringUtils . isEmpty ( query . query ( ) ) ) throw new org . apache . openjpa . util . MetaDataException ( AnnotationPersistenceMetaDataParser . _loc . get ( "no-native-query-string" , query . name ( ) , el ) ) ; if ( _log . isTraceEnabled ( ) ) _log . trace ( AnnotationPersistenceMetaDataParser . _loc . get ( "parse-native-query" , query . name ( ) ) ) ; meta = getRepository ( ) . getCachedQueryMetaData ( null , query . name ( ) ) ; if ( meta != null ) { if ( _log . isWarnEnabled ( ) ) _log . warn ( AnnotationPersistenceMetaDataParser . _loc . get ( "dup-query" , query . name ( ) , el ) ) ; return ; } meta = getRepository ( ) . addQueryMetaData ( null , query . name ( ) ) ; meta . setQueryString ( query . query ( ) ) ; meta . setLanguage ( LANG_SQL ) ; Class res = query . resultClass ( ) ; <START_BUG> if ( ImplHelper . isManagedType ( res ) ) <END_BUG> meta . setCandidateType ( res ) ; else if ( ! ( void . class . equals ( res ) ) ) meta . setResultType ( res ) ; if ( ! ( StringUtils . isEmpty ( query . resultSetMapping ( ) ) ) ) meta . setResultSetMappingName ( query . resultSetMapping ( ) ) ; meta . setSource ( getSourceFile ( ) , ( el instanceof Class ? el : null ) , meta . SRC_ANNOTATIONS ) ; if ( isMetaDataMode ( ) ) meta . setSourceMode ( MODE_META ) ; else if ( isMappingMode ( ) ) meta . setSourceMode ( MODE_MAPPING ) ; else meta . setSourceMode ( MODE_QUERY ) ; } } private static class MethodKey { private final Method _method ; public MethodKey ( Method m ) { } public int hashCode ( ) { } public boolean equals ( Object o ) { } } private static class MethodComparator implements Comparator { private static AnnotationPersistenceMetaDataParser . MethodComparator INSTANCE = null ; public static AnnotationPersistenceMetaDataParser . MethodComparator getInstance ( ) { } public int compare ( Object o1 , Object o2 ) { } } }

Fix:
if ( ImplHelper . isManagedType ( getConfiguration ( ) , res ) )