Program: 66996
Project: 66996
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 primaryKey,LockModeType lockMode,Map<String,Object> properties){
  if (primaryKey == null) {
    throw new IllegalArgumentException(ExceptionLocalization.buildMessage("String_Node_Str"));
  }
  List primaryKeyValues;
  if (primaryKey instanceof List) {
    primaryKeyValues=(List)primaryKey;
  }
 else {
    CMPPolicy policy=descriptor.getCMPPolicy();
    Class pkClass=policy.getPKClass();
    if ((pkClass != null) && (!BasicTypeHelperImpl.getInstance().isAssignableFrom(pkClass,primaryKey.getClass()))) {
      throw new IllegalArgumentException(ExceptionLocalization.buildMessage("String_Node_Str",new Object[]{descriptor.getCMPPolicy().getPKClass(),primaryKey.getClass()}));
    }
    primaryKeyValues=policy.createPkVectorFromKey(primaryKey,session);
  }
  ReadObjectQuery query=descriptor.getQueryManager().getReadObjectQuery();
  if (query == null) {
    query=getReadObjectQuery(descriptor.getJavaClass(),primaryKeyValues,properties);
  }
 else {
    query.checkPrepare(session,null);
    query=(ReadObjectQuery)query.clone();
    QueryHintsHandler.apply(properties,query,session.getLoader());
    query.setIsExecutionClone(true);
    query.setSelectionKey(primaryKeyValues);
  }
  if (properties == null || (!properties.containsKey(QueryHints.CACHE_USAGE) && !properties.containsKey(QueryHints.CACHE_RETRIEVE_MODE) && !properties.containsKey(QueryHints.CACHE_STORE_MODE))) {
    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 primaryKey,LockModeType lockMode,Map<String,Object> properties){
  if (primaryKey == null) {
    throw new IllegalArgumentException(ExceptionLocalization.buildMessage("String_Node_Str"));
  }
  List primaryKeyValues;
  if (primaryKey instanceof List) {
    primaryKeyValues=(List)primaryKey;
  }
 else {
    CMPPolicy policy=descriptor.getCMPPolicy();
    Class pkClass=policy.getPKClass();
    if ((pkClass != null) && (!BasicTypeHelperImpl.getInstance().isStrictlyAssignableFrom(pkClass,primaryKey.getClass()))) {
      throw new IllegalArgumentException(ExceptionLocalization.buildMessage("String_Node_Str",new Object[]{descriptor.getCMPPolicy().getPKClass(),primaryKey.getClass()}));
    }
    primaryKeyValues=policy.createPkVectorFromKey(primaryKey,session);
  }
  ReadObjectQuery query=descriptor.getQueryManager().getReadObjectQuery();
  if (query == null) {
    query=getReadObjectQuery(descriptor.getJavaClass(),primaryKeyValues,properties);
  }
 else {
    query.checkPrepare(session,null);
    query=(ReadObjectQuery)query.clone();
    QueryHintsHandler.apply(properties,query,session.getLoader());
    query.setIsExecutionClone(true);
    query.setSelectionKey(primaryKeyValues);
  }
  if (properties == null || (!properties.containsKey(QueryHints.CACHE_USAGE) && !properties.containsKey(QueryHints.CACHE_RETRIEVE_MODE) && !properties.containsKey(QueryHints.CACHE_STORE_MODE))) {
    query.conformResultsInUnitOfWork();
  }
  return executeQuery(query,lockMode,session);
}