/** * PUBLIC: * Initialize the query to use the specified call. */ public DataReadQuery(Call call) { this(); setCall(call); }
/** * PUBLIC: * Initialize the query to use the specified call. */ public DataReadQuery(Call call) { this(); setCall(call); }
/** * PUBLIC: * Initialize the query to use the specified call. */ public DataReadQuery(Call call) { this(); setCall(call); }
/** * PUBLIC: * Execute the call on the database and return the result. * The call must return a value, if no value is return executeNonSelectCall must be used. * The call can be a stored procedure call, SQL call or other type of call. * A vector of database rows is returned, database row implements Java 2 Map which should be used to access the data. * <p>Example: * <p>session.executeSelectingCall(new SQLCall("Select * from Employee"); * * @see #executeNonSelectingCall(Call) */ @Override public Vector executeSelectingCall(Call call) throws DatabaseException { DataReadQuery query = new DataReadQuery(); query.setCall(call); query.setIsExecutionClone(true); return (Vector)executeQuery(query); }
/** * PUBLIC: * Execute the call on the database and return the result. * The call must return a value, if no value is return executeNonSelectCall must be used. * The call can be a stored procedure call, SQL call or other type of call. * A vector of database rows is returned, database row implements Java 2 Map which should be used to access the data. * <p>Example: * <p>session.executeSelectingCall(new SQLCall("Select * from Employee"); * * @see #executeNonSelectingCall(Call) */ public Vector executeSelectingCall(Call call) throws DatabaseException { DataReadQuery query = new DataReadQuery(); query.setCall(call); query.setIsExecutionClone(true); return (Vector)executeQuery(query); }
/** * PUBLIC: * Execute the call on the database and return the result. * The call must return a value, if no value is return executeNonSelectCall must be used. * The call can be a stored procedure call, SQL call or other type of call. * A vector of database rows is returned, database row implements Java 2 Map which should be used to access the data. * <p>Example: * <p>session.executeSelectingCall(new SQLCall("Select * from Employee"); * * @see #executeNonSelectingCall(Call) */ public Vector executeSelectingCall(Call call) throws DatabaseException { DataReadQuery query = new DataReadQuery(); query.setCall(call); query.setIsExecutionClone(true); return (Vector)executeQuery(query); }
StoredProcedureCall storedProcedureCall = new StoredProcedureCall(); storedProcedureCall.setProcedureName("mypackage.myprocedure"); storedProcedureCall.addNamedArgument("i_input_1"); // Add input argument name. storedProcedureCall.addNamedOutputArgument("o_output_1"); // Add output parameter name. DataReadQuery query = new DataReadQuery(); query.setCall(storedProcedureCall); query.addArgument("i_input_1"); // Add input argument names (again); List<Object> argumentValues = new ArrayList<Object>(); argumentValues.add("valueOf_i_input_1"); // Add input argument values. JpaEntityManager jpaEntityManager = (JpaEntityManager) getEntityManager(); Session session = jpaEntityManager.getActiveSession(); List<?> results = (List<?>) session.executeQuery(query, argumentValues); DatabaseRecord record = (DatabaseRecord) results.get(0); String result = String.valueOf(record.get("o_output_1")); // Get output parameter
/** * INTERNAL: * Execute the call on the database and return the result. Calling this * method will bypass a global setting to disallow native SQL queries. (set * by default when one Entity is marked as multitenant) * * The call must return a value, if no value is return executeNonSelectCall * must be used. * * The call can be a stored procedure call, SQL call or other type of call. * * A vector of database rows is returned, database row implements Java 2 Map * which should be used to access the data. * * <p>Example: * <p>session.executeSelectingCall(new SQLCall("Select * from Employee"); * * @see #priviledgedExecuteNonSelectingCall(Call) */ public Vector priviledgedExecuteSelectingCall(Call call) throws DatabaseException { DataReadQuery query = new DataReadQuery(); query.setAllowNativeSQLQuery(true); query.setCall(call); query.setIsExecutionClone(true); return (Vector)executeQuery(query); }
/** * INTERNAL: * Execute the call on the database and return the result. Calling this * method will bypass a global setting to disallow native SQL queries. (set * by default when one Entity is marked as multitenant) * * The call must return a value, if no value is return executeNonSelectCall * must be used. * * The call can be a stored procedure call, SQL call or other type of call. * * A vector of database rows is returned, database row implements Java 2 Map * which should be used to access the data. * * <p>Example: * <p>session.executeSelectingCall(new SQLCall("Select * from Employee"); * * @see #priviledgedExecuteNonSelectingCall(Call) */ public Vector priviledgedExecuteSelectingCall(Call call) throws DatabaseException { DataReadQuery query = new DataReadQuery(); query.setAllowNativeSQLQuery(true); query.setCall(call); query.setIsExecutionClone(true); return (Vector)executeQuery(query); }
/** * Build a DataReadQuery with the stored procedure call given. */ public static DatabaseQuery buildStoredProcedureQuery(StoredProcedureCall call, Map<String, Object> hints, ClassLoader classLoader, AbstractSession session) { DataReadQuery query = new DataReadQuery(); query.setResultType(DataReadQuery.AUTO); query.setCall(call); query.setIsUserDefined(true); // apply any query hints DatabaseQuery hintQuery = applyHints(hints, query, classLoader, session); // apply any query arguments applyArguments(call, hintQuery); return hintQuery; }