Hi,
your code work fine!!
Thank's for your suggestion.
Now i have another problem. How i can map the resulset readed from stored procedure to my java Object?
Here my code:
--------------------------------------------------------------------------------
.
.
.
QueryResult resultsCollection = new QueryResult();
// run query
ctxt.performQuery(query, resultsCollection);
List outList = resultsCollection.getFirstRows(query);
if (outList.size() > 0) {
Map outParameterValues = (Map) outList.get(0);
DataRow dtr = new DataRow(outParameterValues);
System.out.println(dtr);
User object = (User)ctxt.objectFromDataRow(User.class, dtr, true);
}
--------------------------------------------------------------------------------
I have an error when execute the last line ("User object = (User)ctxt.ob...")
When i use "ctxt.objectFromDataRow" i must have an entry in data map xml file?
Which is the xml tag ("db-entity"?"query"?"obj-entity"?)
I haven't a corresponding db table for my data... the StoredProcedure return the result of a query!
Thank's
:)
Davide
-----Original Message-----
From: Andrus Adamchik [mailto:andru..bjectstyle.org]
Sent: venerd́ 14 gennaio 2005 19.59
To: cayenne-use..bjectstyle.org
Subject: Re: ResultSet with ORACLE Stored Procedure OUT Parameter
For maximum portability CayenneModeler uses JDBC standard types for
mapping, being ignorant of vendor extentions. But OracleAdapter actually
attempts to use OracleTypes.CURSOR when it recognizes it... I guess in
this case it doesn't.
Suggested workaround:
// somewhere on app startup manually update the mapping...
EntityResolver resolver =
Configuration.getSharedConfiguration()
.getDomain()
.getEntityResolver();
Procedure proc = resolver.lookupProcedure(procedureName);
Iterator it = proc.getCallOutParameters().iterator();
while(it.hasNext()) {
ProcedureParameter param = (ProcedureParameter) it.next();
if(param.getType() == Types.OTHER) {
param.setType(OracleAdapter.getOracleCursorType());
}
}
Please post a note how this worked... We may need to add a new feature to
the Modeler to support vendor extentions (we have attribute prototypes
feature request in JIRA, I guess this might go in there).
Andrus
OracleAdapter.getOracleCursorType()
Andrus
> Hi,
> i'm a new Cayenne's user.
> I have a Oracle stored procedure that return a CURSOR by OUT parmeter.
> With Cayenne Modeler i have generated a datamap xml file:
>
> <procedure name="USERLOGIN" schema="xxxx" catalog="xxxx"
> returningValue="true">
> <procedure-parameter name="I_S_USER_ALIAS" type="VARCHAR"
> direction="in"/>
> <procedure-parameter name="O_RC_USERINFO" type="OTHER"
> direction="out"/> <procedure-parameter name="O_N_EXITFLAG"
> type="DECIMAL" length="22" direction="out"/>
> <procedure-parameter name="O_S_EXITMSG" type="VARCHAR"
> direction="out"/>
> </procedure>
>
> O_RC_USERINFO is a REF CURSOR that i want to map to my java Object.
>
> I try to access to stored procedure in that way:
>
>
> DataContext ctxt = DataContext.createDataContext();>
> ProcedureQuery query = new ProcedureQuery("USERLOGIN");
> query.addParameter("I_S_USER_ALIAS", "smith");
> List outList = ctxt.performQuery(query);
>
>
> when i execute the last line (List outList = ctxt.performQuery(query);)
> i found that error:
>
> INFO QueryLogger: *** error.
> java.sql.SQLException: Invalid column type
>
> the problem is referred to the "OTHER" type that is associated to my
> REF CURSOR.
>
> Anyone can help me?
>
> Usually, with JDBC, i use OracleTypes.CURSOR to retrive data from
> this REF CURSOR. Why Cayenne Modeler use "OTHER" type instead?
>
>
> Thank's.
>
> D.
This archive was generated by hypermail 2.0.0 : Mon Jan 17 2005 - 06:18:05 EST