ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From suntoe <qian...@technodia.com.cn>
Subject Spring bean implements dao interfaces automatically based on iBatis
Date Fri, 28 Apr 2006 13:56:05 GMT

http://dao-zero.sourceforge.net

DaoZero is a small Java Spring bean class that can be used to reduce source
of persistence tier which bases on Spring's iBatis support. It's not a
wrapper of Spring iBatis support, but to replace your DAO bean class
directly. In most cases, the only thing you will do is to declare a bean
whose type is "daozero.ibatis.Dao" and tell DaoZero bean what's your DAO
interface, then DaoZero bean will invoke iBatis mapped statement for you. No
more need DAO implementation codes.

DaoZero bean invokes iBatis mapped statement whose name is same as method
name of DAO interface( or abstract class). Both count and index of mapped
statement should be keeped same as method arguments for current
implementation. DaoZero bean is a factory bean which implements
org.springframework.beans.factory.FactoryBean and will create proxy object
that implements DAO interface( or abstract class) for those beans need this
bean which typically service beans. The proxy object takes repsonsibility
for construct parameter map from invocation arguments and pass the parameter
map to iBatis template method, such as queryForObject(), queryForList(),
etc. The proxy object is smart enough to know what you want is a
java.lang.List or a normal Object( but by current DaoZero release, it doen't
support queryForMap() now. ).

That proxy object is created from different way decided by whether required
DAO type is interface or not. If it is interface, the proxy is created using
standard JDK proxy(java.lang.reflect.Proxy), else, the proxy is created
using CGLIB enhancer(net.sf.cglib.proxy.Enhancer). For a CGLIB proxy, it
will try to implement all public abstract methods for the abstract DAO class
proxied.

In fact, I hacked iBatis, have to cast some iBatis interface to her internal
implementation class, because I cannot found how to get parameter map's meta
data by iBatis's API. (So sorry for the bad smell ) 
--
View this message in context: http://www.nabble.com/Spring-bean-implements-dao-interfaces-automatically-based-on-iBatis-t1524667.html#a4140726
Sent from the iBATIS - User - Java forum at Nabble.com.


Mime
View raw message