ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bondre, Prathit" <pbon...@chdist.com>
Subject RE: iBatis Subquery and Date error
Date Thu, 26 Jan 2006 17:25:47 GMT
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="insertQuery" parameterClass="java.util.Map"

            Insert into table 





                        $name$ as name,

                        $effDate$ as date




                        Id = #id#



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 = new HashMap();


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.



Prathit Bondre



View raw message