Von:
eclipselink-users-bounces@xxxxxxxxxxx
[mailto:eclipselink-users-bounces@xxxxxxxxxxx] Im Auftrag von Andrei
Ilitchev
Gesendet: Montag, 6. Juli 2009 15:23
An: EclipseLink User Discussions
Betreff: Re: [eclipselink-users] Rading Functionresult from a
DataModifyQuery
 
 
 
I would keep using
ValueReadQuery,
 
pass property
"eclipselink.jdbc.exclusive-connection.mode" -> "Always"
to createEntityManager method
 
and ProxyUser connection will
be always used.
 
If you use DataModifyQuery
then handle outputParametersDetected event that would contain the retuned
value.
 
----- Original Message ----- 
Sent: Monday, July 06, 2009
9:08 AM
 
Subject: [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
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users