Return-Path: Delivered-To: apmail-ibatis-user-java-archive@www.apache.org Received: (qmail 49456 invoked from network); 26 Jan 2006 17:26:27 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 26 Jan 2006 17:26:27 -0000 Received: (qmail 37379 invoked by uid 500); 26 Jan 2006 17:26:09 -0000 Delivered-To: apmail-ibatis-user-java-archive@ibatis.apache.org Received: (qmail 37341 invoked by uid 500); 26 Jan 2006 17:26:09 -0000 Mailing-List: contact user-java-help@ibatis.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user-java@ibatis.apache.org Delivered-To: mailing list user-java@ibatis.apache.org Received: (qmail 37317 invoked by uid 99); 26 Jan 2006 17:26:09 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 26 Jan 2006 09:26:09 -0800 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=HTML_MESSAGE X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [12.37.1.158] (HELO chmail.chdist.com) (12.37.1.158) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 26 Jan 2006 09:26:08 -0800 x-mimeole: Produced By Microsoft Exchange V6.5.7226.0 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C6229D.8CD4E749" Subject: RE: iBatis Subquery and Date error Date: Thu, 26 Jan 2006 11:25:47 -0600 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: iBatis Subquery and Date error Thread-Index: AcYimFCa10iJHaKIRhmSwqrkAvlIEwABMneg From: "Bondre, Prathit" To: X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N This is a multi-part message in MIME format. ------_=_NextPart_001_01C6229D.8CD4E749 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi Jeff, =20 Thanks for your response. I tried that as well but when I pass in a String with the database specific format it give me a cast mismatch error. "Value not compatible with the datatype of its assignment target". =20 Any ideas? =20 ________________________________ From: Jeff Butler [mailto:jeffgbutler@gmail.com]=20 Sent: Thursday, January 26, 2006 10:48 AM To: user-java@ibatis.apache.org Subject: Re: iBatis Subquery and Date error =20 Yes, iBATIS will do a toString() on the effDate in this case - because it is not a parameter for the SQL, rather it is a substitution value. =20 The solution is to put effDate into the map as a String in the format that your database understands. In other words, you'll have to format the date yourself. =20 Jeff Butler =20 On 1/26/06, Bondre, Prathit wrote:=20 I currently have a query defined in my XML as follows =20 Insert into table=20 Select Address, City, Zip, $name$ as name, $effDate$ as date From Table Where Id =3D #id# =20 When I call it using the HashMap and set the effDate with java.sql.Date object it throws an exception That the value is not compatible with the datatype of the target which is defined in the database as a Date field. Also based on the documentation I also tried to pass in a java.util.Date instead of the java.sql.Date and it got an error=20 "An unexpected token was found" and it seemed like it was passing in the String version of the Date field which included the timestamp in the data and it was choking on the : in the timestamp.=20 =20 How should I be passing the effDate to this query? =20 So far I had HashMap params =3D new HashMap(); Params.put("name","Value") Params.put ("effDate",effDate) // effDate is an instance of java.sql.Date . Also tried with java.util.Date. =20 What am I doing wrong? =20 Any help will be appreciated. =20 Thanks, Prathit Bondre =20 =20 ------_=_NextPart_001_01C6229D.8CD4E749 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

Hi = Jeff,

 

Thanks for your = response.

I tried that as well but when I = pass in a String with the database specific format it give me a cast mismatch = error.

“Value not compatible with = the datatype of its assignment target”.

 

Any = ideas?

 


From: Jeff = Butler [mailto:jeffgbutler@gmail.com]
Sent: Thursday, January = 26, 2006 10:48 AM
To: = user-java@ibatis.apache.org
Subject: Re: iBatis = Subquery and Date error

 

Yes, iBATIS will do a toString() on the effDate in this case - = because it is not a parameter for the SQL, rather it is a substitution = value.

 

The solution is to put effDate into the map as a String in the = format that your database understands.  In other words, you'll have to = format the date yourself.

 

Jeff Butler

 

On 1/26/06, Bondre, Prathit <pbondre@chdist.com> wrote:

I currently have a query defined in my XML as = follows

 

<statement id=3D"insertQuery" parameterClass=3D"java.util.Map" remapResults=3D"true">

    &nbs= p;       Insert into table

    &nbs= p;       Select

    &nbs= p;            = ;       Address,

    &nbs= p;            = ;       City,

    &nbs= p;            = ;       Zip,

    &nbs= p;            = ;       $name$ as name,

    &nbs= p;            = ;       $effDate$ as date

    &nbs= p;       From

    &nbs= p;            = ;       Table

    &nbs= p;       Where

    &nbs= p;            = ;       Id =3D #id#

</statement>

 

When I call it using the HashMap and set the effDate with java.sql.Date = object it throws an exception

That the  value is not compatible with the datatype of the target which = is defined in the database as a Date field.

Also based on the documentation I also tried to pass in a java.util.Date = instead of the java.sql.Date and it got an error

"An unexpected token was found" and it seemed like it was passing in = the String version of the Date field which included the timestamp in the = data and it was choking on the : in the timestamp.

 

How should I be passing the effDate to this = query?

 

So far I had

HashMap params =3D new HashMap();

Params.put("name",= "Value")

Params.put ("effDate",effDate) // effDate is an instance of java.sql.Date = . Also tried with java.util.Date.

 

What am I doing wrong?

 

Any help will be appreciated.

 

Thanks,

Prathit Bondre

 

 

------_=_NextPart_001_01C6229D.8CD4E749--