Program: 64006
Project: 64006
Buggy source:
/** 
 * Find by primary key.
 * @param entityClass - the entity class to find.
 * @param primaryKey - the entity primary key value, or primary key class, or a List of primary key values.
 * @return the found entity instance or null, if the entity does not exist.
 * @throws IllegalArgumentException if the first argument does not denote an entity type or the second argument is not a valid type for that entity's primary key.
 */
protected Object findInternal(ClassDescriptor descriptor,AbstractSession session,Object id,LockModeType lockMode,Map<String,Object> properties){
  if (id == null) {
    throw new IllegalArgumentException(ExceptionLocalization.buildMessage("String_Node_Str"));
  }
  Object primaryKey;
  if (id instanceof List) {
    if (descriptor.getCacheKeyType() == CacheKeyType.ID_VALUE) {
      if (((List)id).isEmpty()) {
        primaryKey=null;
      }
 else {
        primaryKey=((List)id).get(0);
      }
    }
 else {
      primaryKey=new CacheId(((List)id).toArray());
    }
  }
 else   if (id instanceof CacheId) {
    primaryKey=id;
  }
 else {
    CMPPolicy policy=descriptor.getCMPPolicy();
    Class pkClass=policy.getPKClass();
    if ((pkClass != null) && (pkClass != id.getClass()) && (!BasicTypeHelperImpl.getInstance().isStrictlyAssignableFrom(pkClass,id.getClass()))) {
      throw new IllegalArgumentException(ExceptionLocalization.buildMessage("String_Node_Str",new Object[]{descriptor.getCMPPolicy().getPKClass(),id.getClass()}));
    }
    primaryKey=policy.createPrimaryKeyFromId(id,session);
  }
  ReadObjectQuery query=descriptor.getQueryManager().getReadObjectQuery();
  if (query == null) {
    query=getReadObjectQuery(descriptor.getJavaClass(),primaryKey,properties);
  }
 else {
    query.checkPrepare(session,null);
    query=(ReadObjectQuery)query.clone();
    QueryHintsHandler.apply(properties,query,session.getLoader(),session);
    query.setIsExecutionClone(true);
    query.setSelectionId(primaryKey);
  }
  if (properties == null || (!properties.containsKey(QueryHints.CACHE_USAGE) && !properties.containsKey(QueryHints.CACHE_RETRIEVE_MODE) && !properties.containsKey(QueryHints.CACHE_STORE_MODE)&& !properties.containsKey("String_Node_Str")&& !properties.containsKey("String_Node_Str"))) {
    query.conformResultsInUnitOfWork();
  }
  return executeQuery(query,lockMode,session);
}

Fixed version (ground truth):
/** 
 * Find by primary key.
 * @param entityClass - the entity class to find.
 * @param primaryKey - the entity primary key value, or primary key class, or a List of primary key values.
 * @return the found entity instance or null, if the entity does not exist.
 * @throws IllegalArgumentException if the first argument does not denote an entity type or the second argument is not a valid type for that entity's primary key.
 */
protected Object findInternal(ClassDescriptor descriptor,AbstractSession session,Object id,LockModeType lockMode,Map<String,Object> properties){
  if (id == null) {
    throw new IllegalArgumentException(ExceptionLocalization.buildMessage("String_Node_Str"));
  }
  Object primaryKey;
  if (id instanceof List) {
    if (descriptor.getCacheKeyType() == CacheKeyType.ID_VALUE) {
      if (((List)id).isEmpty()) {
        primaryKey=null;
      }
 else {
        primaryKey=((List)id).get(0);
      }
    }
 else {
      primaryKey=new CacheId(((List)id).toArray());
    }
  }
 else   if (id instanceof CacheId) {
    primaryKey=id;
  }
 else {
    CMPPolicy policy=descriptor.getCMPPolicy();
    Class pkClass=policy.getPKClass();
    if ((pkClass != null) && (pkClass != id.getClass()) && (!BasicTypeHelperImpl.getInstance().isStrictlyAssignableFrom(pkClass,id.getClass()))) {
      throw new IllegalArgumentException(ExceptionLocalization.buildMessage("String_Node_Str",new Object[]{descriptor.getCMPPolicy().getPKClass(),id.getClass()}));
    }
    primaryKey=policy.createPrimaryKeyFromId(id,session);
  }
  if (lockMode != null && (lockMode.name().equals(ObjectLevelReadQuery.PESSIMISTIC_READ) || lockMode.name().equals(ObjectLevelReadQuery.PESSIMISTIC_WRITE) || lockMode.name().equals(ObjectLevelReadQuery.PESSIMISTIC_FORCE_INCREMENT))) {
    if (session.isUnitOfWork() && ((UnitOfWorkImpl)session).hasPessimisticLockedObjects()) {
      ReadObjectQuery query=new ReadObjectQuery();
      query.setReferenceClass(descriptor.getJavaClass());
      query.setSelectionId(primaryKey);
      query.checkCacheOnly();
      Object cachedEntity=session.executeQuery(query);
      if (cachedEntity != null && ((UnitOfWorkImpl)session).isPessimisticLocked(cachedEntity)) {
        return cachedEntity;
      }
    }
  }
  ReadObjectQuery query=descriptor.getQueryManager().getReadObjectQuery();
  if (query == null) {
    query=getReadObjectQuery(descriptor.getJavaClass(),primaryKey,properties);
  }
 else {
    query.checkPrepare(session,null);
    query=(ReadObjectQuery)query.clone();
    QueryHintsHandler.apply(properties,query,session.getLoader(),session);
    query.setIsExecutionClone(true);
    query.setSelectionId(primaryKey);
  }
  if (properties == null || (!properties.containsKey(QueryHints.CACHE_USAGE) && !properties.containsKey(QueryHints.CACHE_RETRIEVE_MODE) && !properties.containsKey(QueryHints.CACHE_STORE_MODE)&& !properties.containsKey("String_Node_Str")&& !properties.containsKey("String_Node_Str"))) {
    query.conformResultsInUnitOfWork();
  }
  return executeQuery(query,lockMode,session);
}