ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matthew Hegarty <matthew.hega...@diagonal-consulting.com>
Subject Inserting null into SQLServer DATETIME field
Date Wed, 19 Oct 2005 09:01:06 GMT
All

I am having trouble inserting null values into a SQL Server DATETIME field.

I have specified the following mapping:

<insert id="insertTaskInstance" parameterClass="taskInstance">
    insert into TASK_INSTANCES (START_DATETIME, END_DATETIME, ID_TASK_TYPE,
ID_TASK_STATE)
    values (#startDateTime#, #endDateTime:DATETIME#, #idTaskType#,
#idTaskState#)
	<selectKey resultClass="long">
		SELECT @@IDENTITY AS ID
	</selectKey>
</insert>

If the endDateTime value is null (otherwise is fine) the call to insert
fails with the following error:

junit.framework.AssertionFailedError: DAO Error: Failed to insert - id
[insertTaskInstance], parameterObject [....dto.TaskInstance@11563ff]. Cause:
com.ibatis.common.jdbc.exception.NestedSQLException:   
--- The error occurred in ..../dao/sql/TaskInstanceSQL.xml.  
--- The error occurred while applying a parameter map.  
--- Check the insertTaskInstance-InlineParameterMap.  
--- Check the parameter mapping for the 'endDateTime' property.  
--- Cause: java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for
JDBC]The specified SQL type is not supported by this driver.
Caused by: java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for
JDBC]The specified SQL type is not supported by this driver.
	at junit.framework.Assert.fail(Assert.java:47)

However if I specify '#endDateTime:DATE#' (not DATETIME) an insert of null
is fine (though this is not acceptable for me because when a date is passed
the time portion of the date is lost).
The underlying field is DATETIME (length=8)

I am using the latest SQLMaps DAO release.

Any ideas?

Matt


______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________
Mime
View raw message