ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daryl Stultz <da...@6degrees.com>
Subject XML vs Annotations
Date Fri, 05 Feb 2010 22:15:22 GMT

I think it's great that iBatis supports both XML and annotations. I don't
necessarily prefer one over the other but I kind of prefer to do everything
one way. The docs state that "You will notice that join mapping is not
supported via the Annotations API. This is due to the limitation in Java
Annotations that does not allow for circular references." I'm pretty
experienced with SQL but It's not clear to me exactly what a "join mapping"
is. At first I thought it was a many-to-many. Can someone give me an

If "not everything" can be done with annotations, I'd be inclined to do
mappings in XML but SQL in Java using SelectBuilder. I seem to be having a
little trouble wiring things together. I have my <resultMap> in my mapper
xml file and my Mapper interface specifies the @SelectProvider. The query is
built and executed properly but the mapper returns a null object presumably
because the resultMap isn't being found. How do I configure my mapper
interface and my mapper xml to talk to each other (how do I specify the
resultMap that goes with the mapper method / SelectProvider? I hope that's
clear... if not:

My xml file contains this:

<resultMap id="userResult" type="User">...

It used to contain this before experimenting with @SelectProvider:

<select id="findById" parameterType="Integer" resultMap="userResult">...

My mapper interface contains this:

@SelectProvider(type = UserSql.class, method = "findById")
public User findById(Integer id);

UserSql.findById is being call just fine. What I expected to have to do was
specify @ResultMap or @SelectProvider(resultMap = "userResult") to connect


Daryl Stultz
6 Degrees Software and Consulting, Inc.

View raw message