Execute the statement and return only the first record from the result set.

@param returnType The Class to return.
@param <V> The type parameter.
@return An instance of {@literal <V>} from the result set.
4993
public <V> V executeAndFetchFirst(Class<V> returnType) {
        Object o = executeScalar();
        if (null == o) {
            return null;
        }
        return convert(o, returnType);
    }
1118373
public static String getDesc(Class<?> returnType, Class<?>... paramTypes) {
        StringBuilder sb = new StringBuilder();
        sb.append("(");
        for (Class<?> type : paramTypes) {
            sb.append(ByteCodeUtils.getByteCodeType(type));
        }
        sb.append(")");
        //        sb.append(StringUtils.trim(ByteCodeUtils.getByteCodeType(returnType), ";"));
        sb.append(ByteCodeUtils.getByteCodeType(returnType));
        return sb.toString();
    }
1075723
public OmdbBuilder setResultType(final ResultType resultType) {
        if (!ResultType.isDefault(resultType)) {
            params.add(Param.RESULT, resultType);
        }
        return this;
    }
111583
public JType getGenericReturnType()
  {
    try {
      Type retType = _method.getGenericReturnType();

      if (retType instanceof Class)
  return _loader.forName(((Class) retType).getName());
      else
  return new JTypeWrapper(_loader, (ParameterizedType) retType);
    } catch (NoSuchMethodError e) {
      return getReturnType();
    }

  }
715743
@SuppressWarnings("unchecked")
    public <T> void executeAsync(Call call, final Type returnType, final ApiCallback<T> callback) {
        call.enqueue(new Callback() {
            @Override
            public void onFailure(Request request, IOException e) {
                callback.onFailure(new ApiException(e), 0, null);
            }

            @Override
            public void onResponse(Response response) throws IOException {
                T result;
                try {
                    result = (T) handleResponse(response, returnType);
                } catch (ApiException e) {
                    callback.onFailure(e, response.code(), response.headers().toMultimap());
                    return;
                }
                callback.onSuccess(result, response.code(), response.headers().toMultimap());
            }
        });
    }
1285868
private static RowMapper getMapper(Class<? extends RowMapper> rowMapper, ResultSet rs, Class returnType, Calendar cal)
    {
        Constructor c = null;
        try {
            c = rowMapper.getDeclaredConstructor(_params);
            return (RowMapper) c.newInstance(new Object[]{rs, returnType, cal});
        } catch (NoSuchMethodException e) {
            throw new ControlException("Failure creating new instance of RowMapper, " + e.toString(), e);
        } catch (InstantiationException e) {
            throw new ControlException("Failure creating new instance of RowMapper, " + e.toString(), e);
        } catch (IllegalAccessException e) {
            throw new ControlException("Failure creating new instance of RowMapper, " + e.toString(), e);
        } catch (InvocationTargetException e) {
            throw new ControlException("Failure creating new instance of RowMapper, " + e.getCause().toString(), e);
        }
    }
632340
protected <T> T invokeJavascriptReturnValue(String function, Class<T> returnType, Object... args) {
        Object returnObject = invokeJavascript(function, args);
        if (returnObject != null) {
            return (T) returnObject;
        } else {
            return null;
        }
    }
847878
protected final void declareReturnType(IndentingWriter o, List<IType> intermediates, boolean usesDefaltValues) throws BindingException {
    generateAccessModifier(o);

    if (returnType == null && intermediates == null) {
      o.print("void ");
    } else {
      // we assume that the [retval] param to be passed by reference
      TypeBinding retBinding = TypeBinding.bind(g, returnType, null);

      // add @ReturnValue if necessary
      if ((!retBinding.isDefault && needsMarshalAs()) || (retParam != -1 && (params[retParam].isIn() || retParam != params.length - 1))
          || intermediates != null
          || usesDefaltValues) {
        o.print("@ReturnValue(");
        o.beginCommaMode();
        if (!retBinding.isDefault && needsMarshalAs()) {
          o.comma();
          o.print("type=NativeType." + retBinding.nativeType.name());
        }
        if (retParam != -1 && params[retParam].isIn()) {
          o.comma();
          o.print("inout=true");
        }
        if (retParam != -1 && retParam != params.length - 1 || usesDefaltValues) {
          o.comma();
          o.print("index=" + retParam);
        }

        if (intermediates != null) {
          o.comma();
          o.print("defaultPropertyThrough={");
          o.beginCommaMode();
          for (IType im : intermediates) {
            TypeBinding vb = TypeBinding.bind(g, im, null);
            o.comma();
            o.print(vb.javaType);
            o.print(".class");
          }
          o.endCommaMode();
          o.print("}");
        }

        o.endCommaMode();
        o.println(")");
      }

      o.print(retBinding.javaType);
      o.print(' ');
    }
  }
1284258
public static JKType getType(int typeNumber) {
		JKType sqlDataType = codeToJKTypeMapping.get(typeNumber);
		if (sqlDataType == null) {
			logger.debug("No mapping found for datatype , default mapping will return " + typeNumber);
			return DEFAULT_MAPPING;
		}
		return sqlDataType;
	}
160031
public Binder convert(Class<?> returnType, Class<?>... argTypes) {
        return new Binder(this, new Convert(type()), MethodType.methodType(returnType, argTypes));
    }
177970
public static Class<?> getClassFromType(final Type type) {
        Class<?> returnClass = null;
        if (type instanceof Class<?>) {
            returnClass = (Class<?>) type;
        } else if (type instanceof ParameterizedType) {
            returnClass = getClassFromType(((ParameterizedType) type).getRawType());
        }
        return returnClass;
    }
28067
public String getDefaultReturnValue(HashMap<String,TypeMirror> typeBinding)
    {
        String returnType = getReturnType(typeBinding);
        if (_defaultReturnValues.containsKey(returnType))
            return _defaultReturnValues.get(returnType);
        return "null";
    }
983682
public Object mapRowToReturnType() {

        Object resultObject = null;

        // if the ResultSet only contains a single column we may be able to map directly
        // to the return type -- if so we don't need to build any structures to support
        // mapping
        if (_columnCount == 1) {

            final int typeId = _tmf.getTypeId(_returnTypeClass);

            try {
                if (typeId != TypeMappingsFactory.TYPE_UNKNOWN) {
                    return extractColumnValue(1, typeId);
                } else {
                    // we still might want a single value (i.e. java.util.Date)
                    Object val = extractColumnValue(1, typeId);
                    if (_returnTypeClass.isAssignableFrom(val.getClass())) {
                        return val;
                    }
                }
            } catch (SQLException e) {
                throw new ControlException(e.getMessage(), e);
            }
        }

        if (_fields == null) {
            try {
                getFieldMappings();
            } catch (SQLException e) {
                throw new ControlException(e.getMessage(), e);
            }
        }

        try {
            resultObject = _returnTypeClass.newInstance();
        } catch (InstantiationException e) {
            throw new ControlException("InstantiationException when trying to create instance of : "
                                       + _returnTypeClass.getName(), e);
        } catch (IllegalAccessException e) {
            throw new ControlException("IllegalAccessException when trying to create instance of : "
                                       + _returnTypeClass.getName(), e);
        }

        for (int i = 1; i < _fields.length; i++) {
            AccessibleObject f = _fields[i];
            Object resultValue = null;

            try {
                resultValue = extractColumnValue(i, _fieldTypes[i]);
                if (f instanceof Field) {
                    ((Field) f).set(resultObject, resultValue);
                } else {
                    _args[0] = resultValue;
                    ((Method) f).invoke(resultObject, _args);
                }
            } catch (SQLException e) {
                throw new ControlException(e.getMessage(), e);
            } catch (IllegalArgumentException iae) {

                try {
                    ResultSetMetaData md = _resultSet.getMetaData();
                    if (f instanceof Field) {
                        throw new ControlException("The declared Java type for field " + ((Field) f).getName()
                                                   + ((Field) f).getType().toString()
                                                   + " is incompatible with the SQL format of column " + md.getColumnName(i).toString()
                                                   + md.getColumnTypeName(i).toString()
                                                   + " which returns objects of type " + resultValue.getClass().getName());
                    } else {
                        throw new ControlException("The declared Java type for method " + ((Method) f).getName()
                                                   + ((Method) f).getParameterTypes()[0].toString()
                                                   + " is incompatible with the SQL format of column " + md.getColumnName(i).toString()
                                                   + md.getColumnTypeName(i).toString()
                                                   + " which returns objects of type " + resultValue.getClass().getName());
                    }
                } catch (SQLException e) {
                    throw new ControlException(e.getMessage(), e);
                }

            } catch (IllegalAccessException e) {
                if (f instanceof Field) {
                    throw new ControlException("IllegalAccessException when trying to access field " + ((Field) f).getName(), e);
                } else {
                    throw new ControlException("IllegalAccessException when trying to access method " + ((Method) f).getName(), e);
                }
            } catch (InvocationTargetException e) {
                if (f instanceof Field) {
                    throw new ControlException("InvocationTargetException when trying to access field " + ((Field) f).getName(), e);
                } else {
                    throw new ControlException("InvocationTargetException when trying to access method " + ((Method) f).getName(), e);
                }
            }
        }
        return resultObject;
    }
1359532
public static <ReturnType> ReturnType executeWithSystemPermissions(Callable<ReturnType> task)
        throws ExecutionException {
        ContextAwareCallable<ReturnType> contextAwareCallable = new ContextAwareCallable<ReturnType>(task);
        Subject newsubject = new Subject.Builder().buildSubject();
        newsubject.login(new RootAuthenticationToken());
        try {
            return newsubject.execute(contextAwareCallable);
        } finally {
            newsubject.logout();
        }
    }
1245414
public function SetReturnType(\Peg\Lib\Definitions\Element\ReturnType $return_type)
    {
        $return_type->overload =& $this;
        
        $this->return_type = $return_type;
        
        return $this;
    }
1185887
public Section first(String type) {
        Section result;
        Sections sections = sections(type);
        if (sections != null) {
            result = sections.first();
        }
        else {
            result = null;
        }
        return result;
    }
1043739
public <S> S queryOne(Class<S> type, String sql, Object[] params) {
        Connection conn = getConn();
        try {
            Query query = conn.createQuery(sql)
                    .withParams(params)
                    .setAutoDeriveColumnNames(true)
                    .throwOnMappingFailure(false);

            return ifReturn(AnimaUtils.isBasicType(type),
                    () -> query.executeScalar(type),
                    () -> query.executeAndFetchFirst(type));
        } finally {
            this.closeConn(conn);
            this.clean(null);
        }
    }