two sybase related issues

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

two sybase related issues

Uwe Krueger
Hi ,

I use cayenne on a sybase database with the jTDS driver and I met two
issues.

first:
When I call a stored procedure that return one ResultSet I don't get the
result.
(the procedure doesn't update anything)

Due to fix of CAY-271 the behavior of the method performAction in
ProcedureAction
doesn't work for me anymore.

The return value of the execute method indicate the form of the first
ResultSet. (see JDK API )
So, depend from the return of the execute method the ResultSet should be
read appropriate as updateCount or as  Result.
it seems the getMoreResults is not reliable directly past the execute call

see also:
http://jtds.sourceforge.net/faq.html

second:

the sql type TINYINT is in sybase defined in a range from 0 up to 255
If I do a SQLTemplate query cayenne creates an RowDesriptor from the
ResultSet using
the column type (-6) then map it to Byte.
As long the value is less 128 its OK. But when the value is greater than
127 the
value is wrong.
In MySQL it's also possible to define an unsigned tinyint (0-255).

So, I think it's better to map tinyint to Short at least.


Uwe


Reply | Threaded
Open this post in threaded view
|

Re: two sybase related issues

Andrus Adamchik
> first:
> When I call a stored procedure that return one ResultSet I don't get the
> result. (the procedure doesn't update anything)
>
> Due to fix of CAY-271 the behavior of the method performAction in
> ProcedureAction doesn't work for me anymore.
>
> The return value of the execute method indicate the form of the first
> ResultSet. (see JDK API )
> So, depend from the return of the execute method the ResultSet should be
> read appropriate as updateCount or as  Result.
> it seems the getMoreResults is not reliable directly past the execute call

Could you please open a bug report with a sample stored procedure DDL.

We should definitely add more stored procedure cases to our test suite.
Differences in handling stored procedure results by different drivers is
one of those nasty hidden JDBC gotchas...oh well, we'll try to do
something about it.

Also I must admit that I don't do much testing with jTDS driver (even
though it is often superior to Sybase and MS drivers)... Might be a good
idea to start doing it consistently.


> second:
>
> the sql type TINYINT is in sybase defined in a range from 0 up to 255
> If I do a SQLTemplate query cayenne creates an RowDesriptor from the
> ResultSet using the column type (-6) then map it to Byte.
> As long the value is less 128 its OK. But when the value is greater than
> 127 the value is wrong.
> In MySQL it's also possible to define an unsigned tinyint (0-255).
>
> So, I think it's better to map tinyint to Short at least.

I see no reason to change default mapping between JDBC tinyint and Java
byte - this follows JDBC standard verbatim. If a driver returns JDBC
tinyint for the type that doesn't fit in it, I'd say this is a driver bug.

Of course you'll still have to handle this somehow. Try using #result()
directive in your SQLTemplate
(http://objectstyle.org/cayenne/userguide/fetch/sqltemplate-scripting.html)
to remap a tinyint column to java.lang.Short.

Andrus