Return-Path: Delivered-To: apmail-ibatis-user-java-archive@www.apache.org Received: (qmail 87854 invoked from network); 28 Apr 2006 14:09:08 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 28 Apr 2006 14:09:08 -0000 Received: (qmail 56903 invoked by uid 500); 28 Apr 2006 14:08:58 -0000 Delivered-To: apmail-ibatis-user-java-archive@ibatis.apache.org Received: (qmail 56886 invoked by uid 500); 28 Apr 2006 14:08:58 -0000 Mailing-List: contact user-java-help@ibatis.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user-java@ibatis.apache.org Delivered-To: mailing list user-java@ibatis.apache.org Received: (qmail 56868 invoked by uid 99); 28 Apr 2006 14:08:57 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 28 Apr 2006 07:08:57 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: domain of lists@nabble.com designates 72.21.53.35 as permitted sender) Received: from [72.21.53.35] (HELO talk.nabble.com) (72.21.53.35) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 28 Apr 2006 07:08:57 -0700 Received: from localhost ([127.0.0.1] helo=talk.nabble.com) by talk.nabble.com with esmtp (Exim 4.50) id 1FZTe8-0001rO-KX for user-java@ibatis.apache.org; Fri, 28 Apr 2006 07:08:36 -0700 Message-ID: <4140726.post@talk.nabble.com> Date: Fri, 28 Apr 2006 06:56:05 -0700 (PDT) From: suntoe To: user-java@ibatis.apache.org Subject: Spring bean implements dao interfaces automatically based on iBatis MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Nabble-Sender: qiangyt@technodia.com.cn X-Nabble-From: suntoe X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N 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.