Program: 176290
Project: 176290
Buggy source:
/** 
 * Gets the query implementation.
 * @param jpaQuery the jpa query
 * @param persistenceDelegator the persistence delegator
 * @param persistenceUnits the persistence units
 * @return the query implementation
 */
public Query getQueryImplementation(String jpaQuery,PersistenceDelegator persistenceDelegator,Class mappedClass,boolean isNative){
  if (jpaQuery == null) {
    throw new QueryHandlerException("String_Node_Str");
  }
  KunderaQuery kunderaQuery=new KunderaQuery();
  ApplicationMetadata appMetadata=KunderaMetadata.INSTANCE.getApplicationMetadata();
  String mappedQuery=appMetadata.getQuery(jpaQuery);
  isNative=mappedQuery != null ? appMetadata.isNative(jpaQuery) : isNative;
  EntityMetadata m=null;
  if (!isNative) {
    KunderaQueryParser parser=new KunderaQueryParser(kunderaQuery,mappedQuery != null ? mappedQuery : jpaQuery);
    parser.parse();
    kunderaQuery.postParsingInit();
    m=kunderaQuery.getEntityMetadata();
  }
 else {
    kunderaQuery.isNativeQuery=true;
    m=KunderaMetadataManager.getEntityMetadata(mappedClass);
    Field entityClazzField=null;
    try {
      entityClazzField=kunderaQuery.getClass().getDeclaredField("String_Node_Str");
      if (entityClazzField != null && !entityClazzField.isAccessible()) {
        entityClazzField.setAccessible(true);
      }
      entityClazzField.set(kunderaQuery,mappedClass);
    }
 catch (    Exception e) {
      log.error(e.getMessage());
      throw new QueryHandlerException(e);
    }
  }
  Query query=null;
  try {
    query=getQuery(jpaQuery,persistenceDelegator,m,kunderaQuery);
  }
 catch (  Exception e) {
    log.error(e.getMessage());
    throw new QueryHandlerException(e);
  }
  return query;
}

Fixed version (ground truth):
/** 
 * Gets the query implementation.
 * @param jpaQuery the jpa query
 * @param persistenceDelegator the persistence delegator
 * @param persistenceUnits the persistence units
 * @return the query implementation
 */
public Query getQueryImplementation(String jpaQuery,PersistenceDelegator persistenceDelegator,Class mappedClass,boolean isNative){
  if (jpaQuery == null) {
    throw new QueryHandlerException("String_Node_Str");
  }
  KunderaQuery kunderaQuery=new KunderaQuery();
  ApplicationMetadata appMetadata=KunderaMetadata.INSTANCE.getApplicationMetadata();
  String mappedQuery=appMetadata.getQuery(jpaQuery);
  isNative=mappedQuery != null ? appMetadata.isNative(jpaQuery) : isNative;
  EntityMetadata m=null;
  if (!isNative) {
    KunderaQueryParser parser=new KunderaQueryParser(kunderaQuery,mappedQuery != null ? mappedQuery : jpaQuery);
    parser.parse();
    kunderaQuery.postParsingInit();
    m=kunderaQuery.getEntityMetadata();
  }
 else {
    if (appMetadata.isNative(jpaQuery)) {
      mappedClass=appMetadata.getMappedClass(jpaQuery);
    }
    kunderaQuery.isNativeQuery=true;
    m=KunderaMetadataManager.getEntityMetadata(mappedClass);
    Field entityClazzField=null;
    try {
      entityClazzField=kunderaQuery.getClass().getDeclaredField("String_Node_Str");
      if (entityClazzField != null && !entityClazzField.isAccessible()) {
        entityClazzField.setAccessible(true);
      }
      entityClazzField.set(kunderaQuery,mappedClass);
    }
 catch (    Exception e) {
      log.error(e.getMessage());
      throw new QueryHandlerException(e);
    }
  }
  Query query=null;
  try {
    query=getQuery(jpaQuery,persistenceDelegator,m,kunderaQuery);
  }
 catch (  Exception e) {
    log.error(e.getMessage());
    throw new QueryHandlerException(e);
  }
  return query;
}