Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-users] Rading Functionresult from a DataModifyQuery

Hello,
I'm using ValueReadQuery with StoredFunctionCall to read the Function result.
Now I have to execute the Function as a DataModifyQuery to force EL use ProxyUser.
Is there a Possibility to set ValueReadQuery to by also a DataModifyQuery?

SampleCode:
    public Object executeFunction(String functionName, HashMap<String, Object> params, boolean modifysData) {
    	StoredFunctionCall functionCall = new StoredFunctionCall();
        functionCall.setProcedureName(functionName);
		DatabaseQuery query;
		if (modifysData) {
//Using DataModifyQuery for Functions which modifies Data on Database
			query = new DataModifyQuery();
		} else {
//Using ValueReadQuery for Functions which doesn't modifies Data on Database
			query = new ValueReadQuery();
		}
        query.setCall(functionCall);
        List<Object> args = new ArrayList<Object>();
        for (String key : params.keySet()) {
            functionCall.addNamedArgument(key);
            query.addArgument(key);
            args.add(params.get(key));
        }

       functionCall.setResult("FUNCTION_RESULT");


//Using DataModifyQuery has the effet that the Result is an Integer which (maby) indicates sucsessfull execution and not the Functionresolt it self.
        return getSession().executeQuery(query, args);
    }

Best Regards
Berner Martin
Schweiter Braunviehzuchtverband



Back to the top