You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by dr...@gmx.de on 2006/11/17 17:37:28 UTC

Missing Type-Conversion with Postgres-Jdbc-Driver 8.1-407

Hello,

I have the following problem:

I have a simple object

public class MyObject {
 private String id = "";
 public String getId() { return id; }
 public void setId(String id) { this.id = id; }
}

, a database with a table

CREATE TABLE myobject(id serial NOT NULL)

and a map-file

<sqlMap>
 <parameterMap id="MyObjectParameter" class="main.MyObject">
  <parameter property="id" jdbcType="INTEGER"/>
 </parameterMap>
 <insert id="insertMyObject" parameterMap="MyObjectParameter">
  <selectKey keyProperty="id" resultClass="string">SELECT nextval('myobject_id_seq')</selectKey>
  INSERT INTO myobject (id) VALUES (?)
 </insert>
</sqlMap>


With the Postgres-Jdbc-Driver 7.4.213 everything is ok,
but with 8.1-407-Driver I get an exception
ERROR: column "id" is of type integer but expression is of type character varying
though I have set the jdbcType to INTEGER. So it seems, that there
is no conversion done. What have I done wrong?

Thank you
Dennis
-- 
Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen! 
Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer

Re: Missing Type-Conversion with Postgres-Jdbc-Driver 8.1-407

Posted by "D. Richter" <dr...@gmx.de>.
selectKey has to return the type of the Java-Object-Member, so string
is ok (int doesn't work). If I choose the type int for the member id, 
then it works too, but the String should be converted, because I specified
the destination-type as INTEGER.

Thank You
Dennis

-------- Original-Nachricht --------
Datum: Fri, 17 Nov 2006 09:41:04 -0700
Von: "Brandon Goodin" <br...@gmail.com>
An: user-java@ibatis.apache.org
Betreff: Re: Missing Type-Conversion with Postgres-Jdbc-Driver 8.1-407

> you selectKey is returning a "string". shouldn't it return an "integer"?
> 
> Brandon
> 
> On 11/17/06, dr-ibatis@gmx.de <dr...@gmx.de> wrote:
> >
> > Hello,
> >
> > I have the following problem:
> >
> > I have a simple object
> >
> > public class MyObject {
> > private String id = "";
> > public String getId() { return id; }
> > public void setId(String id) { this.id = id; }
> > }
> >
> > , a database with a table
> >
> > CREATE TABLE myobject(id serial NOT NULL)
> >
> > and a map-file
> >
> > <sqlMap>
> > <parameterMap id="MyObjectParameter" class="main.MyObject">
> >   <parameter property="id" jdbcType="INTEGER"/>
> > </parameterMap>
> > <insert id="insertMyObject" parameterMap="MyObjectParameter">
> >   <selectKey keyProperty="id" resultClass="string">SELECT
> > nextval('myobject_id_seq')</selectKey>
> >   INSERT INTO myobject (id) VALUES (?)
> > </insert>
> > </sqlMap>
> >
> >
> > With the Postgres-Jdbc-Driver 7.4.213 everything is ok,
> > but with 8.1-407-Driver I get an exception
> > ERROR: column "id" is of type integer but expression is of type
> character
> > varying
> > though I have set the jdbcType to INTEGER. So it seems, that there
> > is no conversion done. What have I done wrong?
> >
> > Thank you
> > Dennis
> > --
> > Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!
> > Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer
> >

-- 
Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen! 
Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer

Re: Missing Type-Conversion with Postgres-Jdbc-Driver 8.1-407

Posted by Brandon Goodin <br...@gmail.com>.
you selectKey is returning a "string". shouldn't it return an "integer"?

Brandon

On 11/17/06, dr-ibatis@gmx.de <dr...@gmx.de> wrote:
>
> Hello,
>
> I have the following problem:
>
> I have a simple object
>
> public class MyObject {
> private String id = "";
> public String getId() { return id; }
> public void setId(String id) { this.id = id; }
> }
>
> , a database with a table
>
> CREATE TABLE myobject(id serial NOT NULL)
>
> and a map-file
>
> <sqlMap>
> <parameterMap id="MyObjectParameter" class="main.MyObject">
>   <parameter property="id" jdbcType="INTEGER"/>
> </parameterMap>
> <insert id="insertMyObject" parameterMap="MyObjectParameter">
>   <selectKey keyProperty="id" resultClass="string">SELECT
> nextval('myobject_id_seq')</selectKey>
>   INSERT INTO myobject (id) VALUES (?)
> </insert>
> </sqlMap>
>
>
> With the Postgres-Jdbc-Driver 7.4.213 everything is ok,
> but with 8.1-407-Driver I get an exception
> ERROR: column "id" is of type integer but expression is of type character
> varying
> though I have set the jdbcType to INTEGER. So it seems, that there
> is no conversion done. What have I done wrong?
>
> Thank you
> Dennis
> --
> Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!
> Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer
>