ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Clinton Begin <clinton.be...@gmail.com>
Subject Re: iBatis 3.x.x - documentation error ?
Date Fri, 14 Aug 2009 03:34:47 GMT
corrected.

On Thu, Aug 13, 2009 at 9:22 AM, Clinton Begin <clinton.begin@gmail.com>wrote:

> Yep, that's a typo.  Should be parameterType and resultType....
>
> Clinton
>
> 2009/8/13 Erdem Budak <erdembudak@hotmail.com>
>
>  Hello
>>
>> I trying to write a simple swing gui application using ibatis 3.x.x. I
>> have a few problems doing it with the current documentation. I'll try to
>> explain my problems.
>>
>> 1) The example code for mapper :
>>
>> <select id=”selectPerson” parameterClass=”int” resultClass=”hashmap”>
>> SELECT * FROM PERSON WHERE ID = #{id}
>> </select>
>>
>> Well i can't seem to use parameterClass or resultClass. They are not
>> defined in dtd nor in documentation. I don't know if using parameterType and
>> resultType gives the same result.
>>
>> 2) mapping classes from xml :
>>
>> I dont think it is enough documented. I tried to write a mapper class and
>> could not manage to do it. What i tried to do is.
>>
>> -a UserMapper interface which defines a selectUser function.
>>
>> public interface UserMapper {
>>
>>     public User selectUser(int id);
>>
>> }
>>
>> -a UserMapper.xml
>>
>> <mapper namespace="com.erdm.ibatistest.UserMappe r">
>>     <select id="selectUser" parameterType="int" resultType="hashmap">
>>         SELECT * FROM users WHERE id = #{id}
>>     </select>
>> </mapper>
>>
>> -in my configuration.xml
>>
>> <mappers>
>>     <mapper resource="com/erdm/ibatistest/UserMapper.xml" />
>> </mappers>
>>
>> having the error
>>
>> Exception in thread "AWT-EventQueue-0"
>> org.apache.ibatis.exceptions.IbatisException:
>> ### Error building SqlSession.
>> ### The error may exist in com/erdm/ibatistest/UserMapper.xml
>> ### Cause: org.apache.ibatis.builder.BuilderException: Error parsing SQL
>> Mapper Configuration. Cause: java.lang.RuntimeException: Error parsing
>> Mapper XML. Cause: java.lang.IllegalArgumentException: Mapped Statements
>> collection already contains value for
>> com.erdm.ibatistest.UserMapper.selectUser
>>     at org.apache.ibatis.exceptions.ExceptionFactory.wrap
>> Exception(ExceptionFactory.java:8)
>>     at
>> org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:31)
>>     at
>> org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:14)
>>     at com.erdm.ibatistest.MainJFrame.<init>(MainJFrame.java:164)
>>     at com.erdm.ibatistest.MainJFrame$1.run(MainJFrame.java:70)
>>     at java.awt.event.InvocationEvent.dispatch(Unknown Source)
>>     at java.awt.EventQueue.dispatchEvent(Unknown Source)
>>     at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
>>     at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
>>     at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
>>     at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
>>     at java.awt.Eve ntDispatchThread.pumpEvents(Unknown Source)
>>     at java.awt.EventDispatchThread.run(Unknown Source)
>> Caused by: org.apache.ibatis.builder.BuilderException: Error parsing SQL
>> Mapper Configuration. Cause: java.lang.RuntimeException: Error parsing
>> Mapper XML. Cause: java.lang.IllegalArgumentException: Mapped Statements
>> collection already contains value for
>> com.erdm.ibatistest.UserMapper.selectUser
>>     at
>> org.apache.ibatis.builder.xml.XMLConfigBuilder.parseConfiguration(XMLConfigBuilder.java:62)
>>     at
>> org.apache.ibatis.builder.xml.XMLConfigBuilder.parse(XMLConfigBuilder.java:47)
>>     at
>> org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:28)
>>     ... 11 more
>> Caused by: java.lang.RuntimeException: Error parsing Mapper XML. Cause:
>> java.lang.IllegalArgumentException: Mapped Statements collection already
>> contains value for com.erdm.ibatistest.UserMapper.se lectUser
>>     at
>> org.apache.ibatis.builder.xml.XMLMapperBuilder.configurationElement(XMLMapperBuilder.java:50)
>>     at
>> org.apache.ibatis.builder.xml.XMLMapperBuilder.parse(XMLMapperBuilder.java:31)
>>     at
>> org.apache.ibatis.builder.annotation.MapperAnnotationBuilder.loadXmlResource(MapperAnnotationBuilder.java:50)
>>     at
>> org.apache.ibatis.builder.annotation.MapperAnnotationBuilder.parse(MapperAnnotationBuilder.java:29)
>>     at
>> org.apache.ibatis.binding.MapperRegistry.addMapper(MapperRegistry.java:42)
>>     at
>> org.apache.ibatis.mapping.Configuration.addMapper(Configuration.java:309)
>>     at
>> org.apache.ibatis.builder.xml.XMLMapperBuilder.bindMapperForNamespace(XMLMapperBuilder.java:227)
>>     at
>> org.apache.ibatis.builder.xml.XMLMapperBuilder.parse(XMLMapperBuilder.java:32)
>>     at org.apache.ibatis.builder.xml.XMLConfigBuilder.
>> mapperElement(XMLConfigBuilder.java:221)
>>     at
>> org.apache.ibatis.builder.xml.XMLConfigBuilder.parseConfiguration(XMLConfigBuilder.java:60)
>>     ... 13 more
>> Caused by: java.lang.IllegalArgumentException: Mapped Statements
>> collection already contains value for
>> com.erdm.ibatistest.UserMapper.selectUser
>>     at
>> org.apache.ibatis.mapping.Configuration$StrictMap.put(Configuration.java:349)
>>     at
>> org.apache.ibatis.mapping.Configuration.addMappedStatement(Configuration.java:289)
>>     at
>> org.apache.ibatis.builder.MapperBuilderAssistant.addMappedStatement(MapperBuilderAssistant.java:213)
>>     at
>> org.apache.ibatis.builder.xml.XMLStatementBuilder.parseStatementNode(XMLStatementBuilder.java:59)
>>     at
>> org.apache.ibatis.builder.xml.XMLMapperBuilder.buildStatementFromContext(XMLMapperBuilder.java:185)
>>     at org.apache.ibatis.builder.xml.XMLMapper
>> Builder.configurationElement(XMLMapperBuilder.java:48)
>>     ... 22 more
>>
>> Can't seem to get the mapper class work (old fashion way is fine). I would
>> be glad if you could help me further. Thanks in advance.
>>
>>
>> ------------------------------
>> check out the rest of the Windows Live™. More than mail–Windows Live™ goes
>> way beyond your inbox. More than messages<http://www.microsoft.com/windows/windowslive/>
>>
>
>

Mime
View raw message