Chars haven't been supported to date, because JDBC does not support them. However, I suppose there's no reason why you couldn't build a custom type handler for that....
Clinton On Fri, 28 Jan 2005 11:07:08 +1300, Stephen Chell (DSL AK) <[EMAIL PROTECTED]> wrote: > Hi, > > I'm having trouble mapping an oracle CHAR(1) column to a javabeans > property that is of type "char". I'm using SQL Maps 2.0.9 with Spring > 1.1.3. > > Here is my resultMap (defined in the mapping file ChargeType.xml): > > <resultMap id="result" > class="nz.ac.otago.its.chargeadmin.domain.ChargeType"> > <result property="code" column="CHARGE_TYPE_CODE" > columnIndex="1"/> > <result property="narration" column="NARRATION" > columnIndex="2"/> > <result property="status" column="STATUS" columnIndex="3"/> > <result property="versionNo" column="VERSION_NO" > columnIndex="4"/> > <result property="versionDateTime" column="VERSION_DATE_TIME" > columnIndex="5"/> > <result property="versionUser" column="VERSION_USER" > columnIndex="6"/> > </resultMap> > > The offending column is the status column, which is a CHAR(1) in Oracle > and a char property in the ChargeType class. When I try to execute a > query that uses this result map, the following exception occurs: > > org.springframework.jdbc.UncategorizedSQLException: (SqlMapClient > operation): encountered SQLException [ > --- The error occurred in > nz/ac/otago/its/chargeadmin/dao/ibatis/maps/ChargeType.xml. > --- The error occurred while applying a result map. > --- Check the ChargeType.result. > --- Check the result mapping for the 'status' property. > --- Cause: com.ibatis.sqlmap.client.SqlMapException: No type handler > could be found to map the property 'status' to the column 'STATUS'. One > or both of the types, or the combination of types is not supported.]; > nested exception is com.ibatis.common.jdbc.exception.NestedSQLException: > > --- The error occurred in > nz/ac/otago/its/chargeadmin/dao/ibatis/maps/ChargeType.xml. > --- The error occurred while applying a result map. > --- Check the ChargeType.result. > --- Check the result mapping for the 'status' property. > --- Cause: com.ibatis.sqlmap.client.SqlMapException: No type handler > could be found to map the property 'status' to the column 'STATUS'. One > or both of the types, or the combination of types is not supported. > com.ibatis.common.jdbc.exception.NestedSQLException: > --- The error occurred in > nz/ac/otago/its/chargeadmin/dao/ibatis/maps/ChargeType.xml. > --- The error occurred while applying a result map. > --- Check the ChargeType.result. > --- Check the result mapping for the 'status' property. > --- Cause: com.ibatis.sqlmap.client.SqlMapException: No type handler > could be found to map the property 'status' to the column 'STATUS'. One > or both of the types, or the combination of types is not > supported.Caused by: com.ibatis.sqlmap.client.SqlMapException: No type > handler could be found to map the property 'status' to the column > 'STATUS'. One or both of the types, or the combination of types is not > supported. > at > com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQuery > WithCallback(GeneralStatement.java:183) > at > com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQuery > ForList(GeneralStatement.java:118) > at > com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMap > ExecutorDelegate.java:610) > at > com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMap > ExecutorDelegate.java:584) > at > com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForList(SqlMapSessi > onImpl.java:105) > at > org.springframework.orm.ibatis.SqlMapClientTemplate$3.doInSqlMapClient(S > qlMapClientTemplate.java:202) > at > org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClient > Template.java:142) > at > org.springframework.orm.ibatis.SqlMapClientTemplate.executeWithListResul > t(SqlMapClientTemplate.java:164) > at > org.springframework.orm.ibatis.SqlMapClientTemplate.queryForList(SqlMapC > lientTemplate.java:200) > at > nz.ac.otago.its.chargeadmin.dao.ibatis.SqlMapChargeTypeDao.getChargeType > List(SqlMapChargeTypeDao.java:22) > [etc] > > Explicity specifing the type of the status property in the <result> > element using the javaType and/or jdbcType attributes doesn't help. I > tried all of the following combinations: > > <result property="status" column="STATUS" columnIndex="3" > javaType="char"/> > <result property="status" column="STATUS" columnIndex="3" > javaType="java.lang.Character"/> > <result property="status" column="STATUS" columnIndex="3" > jdbcType="CHAR"/> > <result property="status" column="STATUS" columnIndex="3" > javaType="char" jdbcType="CHAR"/> > <result property="status" column="STATUS" columnIndex="3" > javaType="java.lang.Character" jdbcType="CHAR"/> > > None of these work, although the exception when specifying > javaType="char" is different, as shown below. > > What am I doing wrong? > > Thanks in advance > > Steve > > ------------------------------------------------------------------------ > ---------------- > Exception when specifying javaType="char": > > org.springframework.beans.factory.BeanCreationException: Error creating > bean with name 'sqlMapClient' defined in ServletContext resource > [/WEB-INF/dataAccessContext-local.xml]: Initialization of bean failed; > nested exception is java.lang.RuntimeException: Error occurred. > Cause: com.ibatis.common.xml.NodeletException: Error parsing XML. > Cause: java.lang.RuntimeException: Error parsing XPath > '/sqlMapConfig/sqlMap'. > Cause: com.ibatis.common.xml.NodeletException: Error parsing XML. > Cause: java.lang.RuntimeException: Error parsing XPath > '/sqlMap/resultMap/result'. > Cause: java.lang.RuntimeException: Error. Could not set TypeHandler. > Cause: java.lang.ClassNotFoundException: char > Caused by: java.lang.RuntimeException: Error parsing XPath > '/sqlMap/resultMap/result'. > Cause: java.lang.RuntimeException: Error. Could not set TypeHandler. > Cause: java.lang.ClassNotFoundException: char > Caused by: java.lang.RuntimeException: Error parsing XPath > '/sqlMapConfig/sqlMap'. > Cause: com.ibatis.common.xml.NodeletException: Error parsing XML. > Cause: java.lang.RuntimeException: Error parsing XPath > '/sqlMap/resultMap/result'. > Cause: java.lang.RuntimeException: Error. Could not set TypeHandler. > Cause: java.lang.ClassNotFoundException: char > Caused by: java.lang.RuntimeException: Error parsing XPath > '/sqlMap/resultMap/result'. > Cause: java.lang.RuntimeException: Error. Could not set TypeHandler. > Cause: java.lang.ClassNotFoundException: char > java.lang.RuntimeException: Error occurred. > Cause: com.ibatis.common.xml.NodeletException: Error parsing XML. > Cause: java.lang.RuntimeException: Error parsing XPath > '/sqlMapConfig/sqlMap'. > Cause: com.ibatis.common.xml.NodeletException: Error parsing XML. > Cause: java.lang.RuntimeException: Error parsing XPath > '/sqlMap/resultMap/result'. > Cause: java.lang.RuntimeException: Error. Could not set TypeHandler. > Cause: java.lang.ClassNotFoundException: char > Caused by: java.lang.RuntimeException: Error parsing XPath > '/sqlMap/resultMap/result'. > Cause: java.lang.RuntimeException: Error. Could not set TypeHandler. > Cause: java.lang.ClassNotFoundException: char > Caused by: java.lang.RuntimeException: Error parsing XPath > '/sqlMapConfig/sqlMap'. > Cause: com.ibatis.common.xml.NodeletException: Error parsing XML. > Cause: java.lang.RuntimeException: Error parsing XPath > '/sqlMap/resultMap/result'. > Cause: java.lang.RuntimeException: Error. Could not set TypeHandler. > Cause: java.lang.ClassNotFoundException: char > Caused by: java.lang.RuntimeException: Error parsing XPath > '/sqlMap/resultMap/result'. > Cause: java.lang.RuntimeException: Error. Could not set TypeHandler. > Cause: java.lang.ClassNotFoundException: char > at > com.ibatis.sqlmap.engine.builder.xml.SqlMapConfigParser.parse(SqlMapConf > igParser.java:80) > at > com.ibatis.sqlmap.client.SqlMapClientBuilder.buildSqlMapClient(SqlMapCli > entBuilder.java:62) > at > org.springframework.orm.ibatis.SqlMapClientFactoryBean.afterPropertiesSe > t(SqlMapClientFactoryBean.java:210) > at > org.springframework.beans.factory.support.AbstractAutowireCapableBeanFac > tory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1037) > at > org.springframework.beans.factory.support.AbstractAutowireCapableBeanFac > tory.createBean(AbstractAutowireCapableBeanFactory.java:305) > at > org.springframework.beans.factory.support.AbstractAutowireCapableBeanFac > tory.createBean(AbstractAutowireCapableBeanFactory.java:223) > at > org.springframework.beans.factory.support.AbstractBeanFactory.getBean(Ab > stractBeanFactory.java:236) > at > org.springframework.beans.factory.support.AbstractBeanFactory.getBean(Ab > stractBeanFactory.java:159) > at > org.springframework.beans.factory.support.DefaultListableBeanFactory.pre > InstantiateSingletons(DefaultListableBeanFactory.java:255) > at > org.springframework.context.support.AbstractApplicationContext.refresh(A > bstractApplicationContext.java:317) > at > org.springframework.web.context.support.AbstractRefreshableWebApplicatio > nContext.refresh(AbstractRefreshableWebApplicationContext.java:131) > at > org.springframework.web.context.ContextLoader.createWebApplicationContex > t(ContextLoader.java:177) > at > org.springframework.web.context.ContextLoader.initWebApplicationContext( > ContextLoader.java:105) > at > org.springframework.web.context.ContextLoaderServlet.init(ContextLoaderS > ervlet.java:81) > at javax.servlet.GenericServlet.init(GenericServlet.java:258) > [etc] >

