Monday, March 28, 2005

Idea on Annotaion-based iBATIS SQLMaps (JDK 1.5)

This is my proposal for hacking iBATIS SQLMaps to be annotation-based version.
After looking at the example, I saw the following code:


<select
id="getAddress" parameterClass="int"
resultClass="examples.domain.Address">
select
ADR_ID as id,
ADR_DESCRIPTION as description,
ADR_STREET as street,
ADR_CITY as city,
ADR_PROVINCE as province,
ADR_POSTAL_CODE as postalCode
from ADDRESS
where ADR_ID = #value#
</select>


can be changed to annotation attaching on a method of a Java interface.
#value# should be able to bind with the parameter, like this:


@Sql("select ... ")
public Address getAttress(int value);


Proxy-based AOP is enough for this implementation. A proxy class can be geneated at runtime, using the technique I proposed in SQLWarp.

later...

No comments: