On the other hand, maybe those drivers are following the spec. From
PreparedStatement javadocs:
"void setObject(int parameterIndex, Object x, int targetSqlType)
throws SQLException
Sets the value of the designated parameter with the given object. This
method is like the method setObject above, except that it assumes a
scale of zero."
So truncating a value to scale = 0 is actually appropriate if the
scale is not mapped. Of course something like 'setBigDecimal' would
probably preserve it, so maybe we still need a special ExtendedType to
call this method.
Andrus
On Aug 8, 2008, at 2:28 PM, Andrus Adamchik wrote:
Here is a potential hole. By default (unless ExtendedType is
explicitly defined for a given Java class), Cayenne does the
following JDBC calls:
PreparedStatement st = ..
if (scale != -1) {
st.setObject(pos, val, type, scale);
}
else {
st.setObject(pos, val, type);
}
Looks correct from the JDBC standpoint, but from my experience some
drivers may have it all wrong, and inconsistent with a corresponding
'setSpecificType(..)' method for a given object class. So what is
the class of the object parameter? BigDecimal? Something else?
Andrus
On Aug 8, 2008, at 2:16 PM, Øyvind Harboe wrote:
On Fri, Aug 8, 2008 at 7:53 PM, Andrus Adamchik <[EMAIL PROTECTED]
> wrote:
Cayenne doesn't do anything special on Derby vs. SQLServer in this
respect.
My thinking was that databases behaved differently here and that
Cayenne then either defines that the default behaviour is undefined
when scale is not specified or that Cayenne defines it to be the
same as whatever the database does.
Is this behavior happening for selected objects or when binding a
query
parameter?
First I run an update w/a prepared statement(or rather Cayenne uses
prepared
statements for updates) and afterwards the queries return e.g. "1"
instead of "1.5".
If I run a select statement from *outside* Cayenne, it reveals that
the data in
the database are actually truncated.
Is there a testcase for this in Cayenne?
--
Øyvind Harboe
http://www.zylin.com/zy1000.html
ARM7 ARM9 XScale Cortex
JTAG debugger and flash programmer