ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeff Butler <jeffgbut...@gmail.com>
Subject Re: Way to use sql in mapper interface, without having to create a corresponding xml mapping file?
Date Thu, 13 May 2010 20:35:10 GMT
It took me a while to figure it out also!

Create your SqlSessionFactory as normal, then add the interfaces manually:


Jeff Butler

On Wed, May 12, 2010 at 4:16 PM, Rick R <rickcr@gmail.com> wrote:
> Larry showed me his cool no xml config setup which I'd love to implement at
> some point.
> For this current project using ibatis3 it's too late to refactor a real lot
> at this stage and we're using your typical sqlMapConfig file.  Overall we
> still prefer to code all of our sql in xml files, but I just recently
> decided to create some sql using the annotation-based approach in an
> interface mapper file.
> The problem (?) is that even though all the sql is in this mapper interface,
> I seem to still have to declare a dummy corresponding mapping xml file just
> to declare the interface namespace (otherwise ibatis at runtime bitches
> about not being able to find the mapping.)  I looked over the ibatis3 pdf
> and under the annotation approach section for using Mappers it doesn't
> really mention that you need the corresponding mapping.xml file, so I'm
> probably just missing something stupid?
> Shouldn't there be a way in the SqlMapConfig to declare "Use this interface
> mapper" ? Basically I was thinking in the mapper section of the config
> instead of having to use:
> <mappers>
>    <mapper resource="mapper-files/metadb/DataReleaseMapper.xml"/>
> You could also include:
> <mappers>
>    <mapper class="com.foobar.mapper.DataReleaseMapper"/>
> As it is now, I'm having to declare that silly DataReleaseMapper.xml which
> only ends up wrapping my interface Mapper.
> <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper
>         PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN"
>         "http://ibatis.apache.org/dtd/ibatis-3-mapper.dtd">
>      <mapper
> namespace="com.foo.dataselector.media.service.mapper.DataReleaseMapper">
> </mapper>
> My assumption is that I'm missing something obvious:)

To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org

View raw message