This s probably related to another ExtendedTypes discussion going in
parallel on this list... A binding of Long object is handled by
org.objectstyle.cayenne.access.types.DefaultType which binds values via
statement.setObject(pos, value, type)
I suspect Oracle JDBC driver doesn't implement "setObject" properly, and
requires an explicit call to setLong()... So I guess you need to register
a custom ExtendedType similar to what we have for DoubleType inside
OracleAdapter already. E.g.:
public class OracleLongType extends DefaultType {
public OracleLongType() {
super(Long.class.getName());
}
public void setJdbcObject(
PreparedStatement st,
Object val,
int pos,
int type,
int precision) throws Exception {
if (val != null) {
st.setLong(pos, ((Long) val).longValue());
}
else {
super.setJdbcObject(st, val, pos, type, precision);
}
}
}
Follow this link for further details:
http://objectstyle.org/cayenne/userguide/access-stack/extended-types.html
Also I think we may need to add this code to Oracle adapter. Let us know
if this worked. ...
Andrus
> Hi,
> i want to call a stored procedure that accept a NUMBER in input (es.
> user id).
>
> procedure.addParameter("user_id", new Long(12345));
>
> If i add a Long value, cayenne return an error.
> INFO QueryLogger: *** error.
> java.sql.SQLException: Tipo di colonna non valido
> at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
>
> The only type that works correctly is a Integer.
>
> procedure.addParameter("user_id", new Integer(12345));
>
> How i can pass a Long value instead?
>
>
> Thank's
> Davide
This archive was generated by hypermail 2.0.0 : Wed Jan 26 2005 - 11:23:47 EST