Re: smallint mapping issue
От | Oliver Jowett |
---|---|
Тема | Re: smallint mapping issue |
Дата | |
Msg-id | 42E80EF4.6000505@opencloud.com обсуждение исходный текст |
Ответ на | smallint mapping issue (Christian Cryder <c.s.cryder@gmail.com>) |
Ответы |
Re: smallint mapping issue
|
Список | pgsql-jdbc |
Christian Cryder wrote: > Dave tells me this has been discussed recently, but doesn't recall the > thread, so I'll post here. You might want to search on archives.postgresql.org too. > In postgresql-8.0-311.jdbc3.jar with a column defined as smallint, the > corresponding value returned from getObject() is a Short. > > In the current HEAD, that same smallint column is returned as an Integer. Please see table B-3 in the JDBC 3.0 spec: TABLE B-3 JDBC Types Mapped to Java Object Types ResultSet.getObject and CallableStatement.getObject use the mapping shown in this table for standard mappings [...] TINYINT Integer SMALLINT Integer INTEGER Integer BIGINT Long > This causes HUGE problems if it's not an oversight, as it makes it > virtually impossible to write JDBC code that works with other dbs > (which typically return Short). Which other DBs exactly? You should tell them to fix their JDBC drivers :) It's easy enough to deal with both Short and Integer being returned -- cast to java.lang.Number. > Can someone confirm that this is a bug, and if not, a) why (given the > above documentation), and b) how do you expect to deal with the > incompatibility issues this would cause? It's not a bug -- it's a deliberate change so that we actually follow the spec. Personally I'm not prepared to put much effort into supporting backwards compatibility with old behaviour that was not spec compliant. Fix your application. -O
В списке pgsql-jdbc по дате отправления: