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 ChippyJoey <co...@earthlink.net> on 2010/01/31 23:03:31 UTC
Ibatis 3 Insert Error
Hi –
I am new to Ibatis and I have run into an issue regarding inserts into a
table. I am getting the following error when I attempt to insert data into a
table:
DEBUG [main] - Checked out connection 14247087 from pool.
DEBUG [main] - ooo Connection Opened
DEBUG [main] - ==> Executing: insert into dbo.[Key] (KeyId, KeyValue)
values (?, ?)
DEBUG [main] - ==> Parameters: 1(String), Test 147(String)
java.lang.ClassCastException: java.lang.Integer
at $Proxy4.insertKey(Unknown Source)
at com.catalog.model.dao.impl.KeyImpl.insertKey(KeyImpl.java:21)
at com.catalog.appl.Import.addKey(Import.java:74)
at com.catalog.appl.Import.importFiles(Import.java:33)
at com.catalog.appl.Import.main(Import.java:204)
DEBUG [main] - xxx Connection Closed
DEBUG [main] - Returned connection 14247087 to pool.
The table that I am attempting to insert into has the following definition:
CREATE TABLE [dbo].[Key](
[KeyId] [nchar](10) NULL,
[KeyValue] [nchar](10) NULL
) ON [PRIMARY]
I am using the following SQL map for inserts into the Key table:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN"
"http://ibatis.apache.org/dtd/ibatis-3-mapper.dtd">
<mapper namespace="com.catalog.model.dao.KeyMapper">
<insert id="insertKey" parameterType="com.catalog.model.Key">
insert into dbo.[Key]
(KeyId, KeyValue)
values
(#{keyid}, #{keyvalue})
</insert>
</mapper>
I have the following environment:
Ibatis 3 (ibatis-3-core-3.0.0.227.jar)
Java 1.5
SQL Server 2008 Express
Whats interesting about the error is that the Key table does not even have
an Integer type that could cause a casting problem. I am wondering if the
casting issue is occurring as a result of Ibatis attempting to handle the
row count after the insert has completed (i.e. 1 row inserted). I am sure I
am doing something wrong but I am not sure what it is. Any help would be
greatly appreciated.
Thanks in advance.
- Chip
--
View this message in context: http://old.nabble.com/Ibatis-3-Insert-Error-tp27397120p27397120.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org
Re: Ibatis 3 Insert Error
Posted by Clinton Begin <cl...@gmail.com>.
Right... insert cannot return type Key. It must return an integer, which is
the number of rows inserted.
Clinton
On Sun, Jan 31, 2010 at 7:00 PM, Chip Owen <co...@earthlink.net> wrote:
> Clinton –
>
>
>
> Here is the Key mapper interface definition:
>
>
>
> package com.catalog.model.dao;
>
>
>
> import java.util.List;
>
>
>
> import com.catalog.model.Key;
>
>
>
> public interface KeyMapper {
>
> Key insertKey(Key key);
>
>
>
> Key selectKey(int keyid);
>
>
>
> List<Key> selectKeys();
>
> }
>
>
>
> Currently, I have the return type from insertKey as “Key”. Presumbably,
> this would be a key object containing the newly created key object and key
> id.
>
>
>
> - Chip
>
>
> ------------------------------
>
> *From:* Clinton Begin [mailto:clinton.begin@gmail.com]
> *Sent:* Sunday, January 31, 2010 8:41 PM
> *To:* user-java@ibatis.apache.org
> *Subject:* Re: Ibatis 3 Insert Error
>
>
>
> What's the return type of the mapper method?
>
> Clinton
>
> On Sun, Jan 31, 2010 at 3:03 PM, ChippyJoey <co...@earthlink.net>
> wrote:
>
>
> Hi –
>
> I am new to Ibatis and I have run into an issue regarding inserts into a
> table. I am getting the following error when I attempt to insert data into
> a
> table:
>
> DEBUG [main] - Checked out connection 14247087 from pool.
> DEBUG [main] - ooo Connection Opened
> DEBUG [main] - ==> Executing: insert into dbo.[Key] (KeyId, KeyValue)
> values (?, ?)
> DEBUG [main] - ==> Parameters: 1(String), Test 147(String)
> java.lang.ClassCastException: java.lang.Integer
> at $Proxy4.insertKey(Unknown Source)
> at com.catalog.model.dao.impl.KeyImpl.insertKey(KeyImpl.java:21)
> at com.catalog.appl.Import.addKey(Import.java:74)
> at com.catalog.appl.Import.importFiles(Import.java:33)
> at com.catalog.appl.Import.main(Import.java:204)
> DEBUG [main] - xxx Connection Closed
> DEBUG [main] - Returned connection 14247087 to pool.
>
> The table that I am attempting to insert into has the following definition:
>
> CREATE TABLE [dbo].[Key](
> [KeyId] [nchar](10) NULL,
> [KeyValue] [nchar](10) NULL
> ) ON [PRIMARY]
>
> I am using the following SQL map for inserts into the Key table:
>
> <?xml version="1.0" encoding="UTF-8" ?>
> <!DOCTYPE mapper PUBLIC "-//ibatis.apache.org//DTD<http://ibatis.apache.org/DTD>Mapper 3.0//EN"
> "http://ibatis.apache.org/dtd/ibatis-3-mapper.dtd">
> <mapper namespace="com.catalog.model.dao.KeyMapper">
> <insert id="insertKey" parameterType="com.catalog.model.Key">
> insert into dbo.[Key]
> (KeyId, KeyValue)
> values
>
> (#{keyid}, #{keyvalue})
> </insert>
> </mapper>
>
> I have the following environment:
>
> Ibatis 3 (ibatis-3-core-3.0.0.227.jar)
> Java 1.5
> SQL Server 2008 Express
>
> Whats interesting about the error is that the Key table does not even have
> an Integer type that could cause a casting problem. I am wondering if the
> casting issue is occurring as a result of Ibatis attempting to handle the
> row count after the insert has completed (i.e. 1 row inserted). I am sure I
> am doing something wrong but I am not sure what it is. Any help would be
> greatly appreciated.
>
> Thanks in advance.
>
> - Chip
>
> --
> View this message in context:
> http://old.nabble.com/Ibatis-3-Insert-Error-tp27397120p27397120.html
> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
> For additional commands, e-mail: user-java-help@ibatis.apache.org
>
>
>
RE: Ibatis 3 Insert Error
Posted by Chip Owen <co...@earthlink.net>.
Clinton -
Here is the Key mapper interface definition:
package com.catalog.model.dao;
import java.util.List;
import com.catalog.model.Key;
public interface KeyMapper {
Key insertKey(Key key);
Key selectKey(int keyid);
List<Key> selectKeys();
}
Currently, I have the return type from insertKey as "Key". Presumbably, this
would be a key object containing the newly created key object and key id.
- Chip
_____
From: Clinton Begin [mailto:clinton.begin@gmail.com]
Sent: Sunday, January 31, 2010 8:41 PM
To: user-java@ibatis.apache.org
Subject: Re: Ibatis 3 Insert Error
What's the return type of the mapper method?
Clinton
On Sun, Jan 31, 2010 at 3:03 PM, ChippyJoey <co...@earthlink.net> wrote:
Hi -
I am new to Ibatis and I have run into an issue regarding inserts into a
table. I am getting the following error when I attempt to insert data into a
table:
DEBUG [main] - Checked out connection 14247087 from pool.
DEBUG [main] - ooo Connection Opened
DEBUG [main] - ==> Executing: insert into dbo.[Key] (KeyId, KeyValue)
values (?, ?)
DEBUG [main] - ==> Parameters: 1(String), Test 147(String)
java.lang.ClassCastException: java.lang.Integer
at $Proxy4.insertKey(Unknown Source)
at com.catalog.model.dao.impl.KeyImpl.insertKey(KeyImpl.java:21)
at com.catalog.appl.Import.addKey(Import.java:74)
at com.catalog.appl.Import.importFiles(Import.java:33)
at com.catalog.appl.Import.main(Import.java:204)
DEBUG [main] - xxx Connection Closed
DEBUG [main] - Returned connection 14247087 to pool.
The table that I am attempting to insert into has the following definition:
CREATE TABLE [dbo].[Key](
[KeyId] [nchar](10) NULL,
[KeyValue] [nchar](10) NULL
) ON [PRIMARY]
I am using the following SQL map for inserts into the Key table:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//ibatis.apache.org//DTD
<http://ibatis.apache.org/DTD> Mapper 3.0//EN"
"http://ibatis.apache.org/dtd/ibatis-3-mapper.dtd">
<mapper namespace="com.catalog.model.dao.KeyMapper">
<insert id="insertKey" parameterType="com.catalog.model.Key">
insert into dbo.[Key]
(KeyId, KeyValue)
values
(#{keyid}, #{keyvalue})
</insert>
</mapper>
I have the following environment:
Ibatis 3 (ibatis-3-core-3.0.0.227.jar)
Java 1.5
SQL Server 2008 Express
Whats interesting about the error is that the Key table does not even have
an Integer type that could cause a casting problem. I am wondering if the
casting issue is occurring as a result of Ibatis attempting to handle the
row count after the insert has completed (i.e. 1 row inserted). I am sure I
am doing something wrong but I am not sure what it is. Any help would be
greatly appreciated.
Thanks in advance.
- Chip
--
View this message in context:
http://old.nabble.com/Ibatis-3-Insert-Error-tp27397120p27397120.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org
Re: Ibatis 3 Insert Error
Posted by Clinton Begin <cl...@gmail.com>.
What's the return type of the mapper method?
Clinton
On Sun, Jan 31, 2010 at 3:03 PM, ChippyJoey <co...@earthlink.net> wrote:
>
> Hi –
>
> I am new to Ibatis and I have run into an issue regarding inserts into a
> table. I am getting the following error when I attempt to insert data into
> a
> table:
>
> DEBUG [main] - Checked out connection 14247087 from pool.
> DEBUG [main] - ooo Connection Opened
> DEBUG [main] - ==> Executing: insert into dbo.[Key] (KeyId, KeyValue)
> values (?, ?)
> DEBUG [main] - ==> Parameters: 1(String), Test 147(String)
> java.lang.ClassCastException: java.lang.Integer
> at $Proxy4.insertKey(Unknown Source)
> at com.catalog.model.dao.impl.KeyImpl.insertKey(KeyImpl.java:21)
> at com.catalog.appl.Import.addKey(Import.java:74)
> at com.catalog.appl.Import.importFiles(Import.java:33)
> at com.catalog.appl.Import.main(Import.java:204)
> DEBUG [main] - xxx Connection Closed
> DEBUG [main] - Returned connection 14247087 to pool.
>
> The table that I am attempting to insert into has the following definition:
>
> CREATE TABLE [dbo].[Key](
> [KeyId] [nchar](10) NULL,
> [KeyValue] [nchar](10) NULL
> ) ON [PRIMARY]
>
> I am using the following SQL map for inserts into the Key table:
>
> <?xml version="1.0" encoding="UTF-8" ?>
> <!DOCTYPE mapper PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN"
> "http://ibatis.apache.org/dtd/ibatis-3-mapper.dtd">
> <mapper namespace="com.catalog.model.dao.KeyMapper">
> <insert id="insertKey" parameterType="com.catalog.model.Key">
> insert into dbo.[Key]
> (KeyId, KeyValue)
> values
>
> (#{keyid}, #{keyvalue})
> </insert>
> </mapper>
>
> I have the following environment:
>
> Ibatis 3 (ibatis-3-core-3.0.0.227.jar)
> Java 1.5
> SQL Server 2008 Express
>
> Whats interesting about the error is that the Key table does not even have
> an Integer type that could cause a casting problem. I am wondering if the
> casting issue is occurring as a result of Ibatis attempting to handle the
> row count after the insert has completed (i.e. 1 row inserted). I am sure I
> am doing something wrong but I am not sure what it is. Any help would be
> greatly appreciated.
>
> Thanks in advance.
>
> - Chip
>
> --
> View this message in context:
> http://old.nabble.com/Ibatis-3-Insert-Error-tp27397120p27397120.html
> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
> For additional commands, e-mail: user-java-help@ibatis.apache.org
>
>