ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rick R <ric...@gmail.com>
Subject Way to use sql in mapper interface, without having to create a corresponding xml mapping file?
Date Wed, 12 May 2010 21:16:50 GMT
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:

   <mapper resource="mapper-files/metadb/DataReleaseMapper.xml"/>

You could also include:

   <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"



My assumption is that I'm missing something obvious:)

View raw message