I'm new to iBatis, starting out with version 3. One common usage
scenario we have is to run different queries that all return the same
result type, sliced and diced different ways. Using XML, this is easy
to achieve as I can have all selects refer to the same ResultMap. I
can't figure out how to implement a similar approach using @Results
annotation.
Here is my first example using annotations:
public interface BundleMapper
{
@Select(value="select * from bundle where bundle_id = #{id}")
@Results(value=
{
@Result(column="cust_id", property="custId"),
@Result(column="status_dt", property="statusDt")
})
Bundle selectBundle(String id);
}
My Bundle class contains about 30-40 fields, but I just wanted to save
some typing so I just created two. This approach seems to require me to
define @Results for each select. So if I had another method that also
returned Bundle, I'd have to define the 40-line @Results annotation again.
Using annotations, is there any way to define an @Results mapping one
time and then refer to it multiple times from different methods?
Also, I think it would be handy to merge XML definitions and annotation
definitions into a single application-wide namespace, so that I could
refer to XML definitions from annotations. That would address the issue
I'm discussing here. I could define a ResultMap in XML, then refer to
it as needed from annotations.
Thanks.
--
Guy Rouillier
---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscr...@ibatis.apache.org
For additional commands, e-mail: user-java-h...@ibatis.apache.org