锘??xml version="1.0" encoding="utf-8" standalone="yes"?>一区二区三区波多野结衣在线观看 ,99精品国产福利在线观看免费,国产三级在线http://www.aygfsteel.com/keweibo/category/43121.html涓涓? Java 澶氳兘 Delphi,Powerbuilder ... zh-cnSat, 06 Aug 2011 06:18:24 GMTSat, 06 Aug 2011 06:18:24 GMT60mybatis3.05 鍒嗛〉鏀惰棌http://www.aygfsteel.com/keweibo/articles/355693.htmlKeKeWed, 03 Aug 2011 09:15:00 GMThttp://www.aygfsteel.com/keweibo/articles/355693.htmlhttp://www.aygfsteel.com/keweibo/comments/355693.htmlhttp://www.aygfsteel.com/keweibo/articles/355693.html#Feedback0http://www.aygfsteel.com/keweibo/comments/commentRss/355693.htmlhttp://www.aygfsteel.com/keweibo/services/trackbacks/355693.html浠ヤ笅鍏у渚嗚嚜:
http://zhaohe162.blog.163.com/blog/static/38216797201131262952990/

1.鎶奾ibernate涓嬬殑dialect鍖呭叏閮ㄦ嫹璐濆埌mybatis鍖呯殑jdbc鐩綍涓嬶紝濡備笅鍥炬墍紺猴細

mybatis涓嬬殑鍒嗛〉錛屾敮鎸佹墍鏈夌殑鏁版嵁搴?- 鏂皹浼ょ棔 - 鏂皹灞? style=
 



2.瀹氫箟涓涓猂esultSetHandler  Interceptor

package cn.machi.utils;

import java.sql.Statement;
import java.util.Properties;

import org.apache.ibatis.executor.resultset.FastResultSetHandler;
import org.apache.ibatis.executor.resultset.ResultSetHandler;
import org.apache.ibatis.plugin.Interceptor;
import org.apache.ibatis.plugin.Intercepts;
import org.apache.ibatis.plugin.Invocation;
import org.apache.ibatis.plugin.Plugin;
import org.apache.ibatis.plugin.Signature;
import org.apache.ibatis.session.RowBounds;

@Intercepts( {@Signature(type = ResultSetHandler.class, method = "handleResultSets", args = {Statement.class})})
public class DiclectResultSetHandlerInterceptor implements Interceptor
{
   
    public Object intercept(Invocation invocation) throws Throwable
    {
        FastResultSetHandler resultSet = (FastResultSetHandler)invocation.getTarget();
       
        RowBounds rowBounds = (RowBounds)ReflectUtil.getFieldValue(resultSet,
                "rowBounds");
       
        if (rowBounds.getLimit() > 0
                && rowBounds.getLimit() < RowBounds.NO_ROW_LIMIT)
        {
            ReflectUtil.setFieldValue(resultSet, "rowBounds", new RowBounds());
        }
        return invocation.proceed();
    }
   
    public Object plugin(Object target)
    {
        return Plugin.wrap(target, this);
    }
   
    public void setProperties(Properties properties)
    {
    }
}

 

3.瀹氫箟涓涓猄tatementHandler鐨処nterceptor

package cn.machi.utils;

import java.sql.Connection;
import java.util.Properties;

import org.apache.ibatis.executor.statement.PreparedStatementHandler;
import org.apache.ibatis.executor.statement.RoutingStatementHandler;
import org.apache.ibatis.executor.statement.StatementHandler;
import org.apache.ibatis.jdbc.dialect.OracleDialect;
import org.apache.ibatis.mapping.BoundSql;
import org.apache.ibatis.plugin.Interceptor;
import org.apache.ibatis.plugin.Intercepts;
import org.apache.ibatis.plugin.Invocation;
import org.apache.ibatis.plugin.Plugin;
import org.apache.ibatis.plugin.Signature;
import org.apache.ibatis.session.RowBounds;

@Intercepts( {@Signature(type = StatementHandler.class, method = "prepare", args = {Connection.class})})
public class DiclectStatementHandlerInterceptor implements Interceptor
{
   
    private static final String DIALECT = "org.apache.ibatis.jdbc.dialect.OracleDialect";
   
    public Object intercept(Invocation invocation) throws Throwable
    {
        RoutingStatementHandler statement = (RoutingStatementHandler)invocation.getTarget();
        PreparedStatementHandler handler = (PreparedStatementHandler)ReflectUtil.getFieldValue(statement,
                "delegate");
        RowBounds rowBounds = (RowBounds)ReflectUtil.getFieldValue(handler,
                "rowBounds");
       
        if (rowBounds.getLimit() > 0
                && rowBounds.getLimit() < RowBounds.NO_ROW_LIMIT)
        {
            BoundSql boundSql = statement.getBoundSql();
            String sql = boundSql.getSql();
           
            OracleDialect dialect = (OracleDialect)Class.forName(DIALECT)
                    .newInstance();
            sql = dialect.getLimitString(sql,
                    rowBounds.getOffset(),
                    rowBounds.getLimit());
           
            ReflectUtil.setFieldValue(boundSql, "sql", sql);
        }
        return invocation.proceed();
    }
   
    public Object plugin(Object target)
    {
        return Plugin.wrap(target, this);
    }
   
    public void setProperties(Properties properties)
    {
    }
}

4.瀹氫箟宸ュ叿綾籖eflectUtil

package cn.machi.utils;

import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;

import org.apache.log4j.Logger;


public class ReflectUtil
{
    private static Logger log = Logger.getLogger(ReflectUtil.class);
   
    private static Object operate(Object obj, String fieldName,
            Object fieldVal, String type)
    {
        Object ret = null;
        try
        {
            // 鑾峰緱瀵硅薄綾誨瀷 
            Class<? extends Object> classType = obj.getClass();
            // 鑾峰緱瀵硅薄鐨勬墍鏈夊睘鎬?nbsp;
            Field fields[] = classType.getDeclaredFields();
            for (int i = 0; i < fields.length; i++)
            {
                Field field = fields[i];
                if (field.getName().equals(fieldName))
                {
                   
                    String firstLetter = fieldName.substring(0, 1)
                            .toUpperCase(); // 鑾峰緱鍜屽睘鎬у搴旂殑getXXX()鏂規(guī)硶鐨勫悕瀛?nbsp;
                    if ("set".equals(type))
                    {
                        String setMethodName = "set" + firstLetter
                                + fieldName.substring(1); // 鑾峰緱鍜屽睘鎬у搴旂殑getXXX()鏂規(guī)硶 
                        Method setMethod = classType.getMethod(setMethodName,
                                new Class[] {field.getType()}); // 璋冪敤鍘熷璞$殑getXXX()鏂規(guī)硶 
                        ret = setMethod.invoke(obj, new Object[] {fieldVal});
                    }
                    if ("get".equals(type))
                    {
                        String getMethodName = "get" + firstLetter
                                + fieldName.substring(1); // 鑾峰緱鍜屽睘鎬у搴旂殑setXXX()鏂規(guī)硶鐨勫悕瀛?nbsp;
                        Method getMethod = classType.getMethod(getMethodName,
                                new Class[] {});
                        ret = getMethod.invoke(obj, new Object[] {});
                    }
                    return ret;
                }
            }
        }
        catch (Exception e)
        {
            log.warn("reflect error:" + fieldName, e);
        }
        return ret;
    }
   
    public static Object getVal(Object obj, String fieldName)
    {
        return operate(obj, fieldName, null, "get");
    }
   
    public static void setVal(Object obj, String fieldName, Object fieldVal)
    {
        operate(obj, fieldName, fieldVal, "set");
    }
   
   
    private static Method getDeclaredMethod(Object object, String methodName,
            Class<?>[] parameterTypes)
    {
        for (Class<?> superClass = object.getClass(); superClass != Object.class; superClass = superClass.getSuperclass())
        {
            try
            {
                //superClass.getMethod(methodName, parameterTypes);
                return superClass.getDeclaredMethod(methodName, parameterTypes);
            }
            catch (NoSuchMethodException e)
            {
                //Method 涓嶅湪褰撳墠綾誨畾涔? 緇х畫鍚戜笂杞瀷
            }
        }
       
        return null;
    }
   
   
    private static void makeAccessible(Field field)
    {
        if (!Modifier.isPublic(field.getModifiers()))
        {
            field.setAccessible(true);
        }
    }
   
   
    private static Field getDeclaredField(Object object, String filedName)
    {
        for (Class<?> superClass = object.getClass(); superClass != Object.class; superClass = superClass.getSuperclass())
        {
            try
            {
                return superClass.getDeclaredField(filedName);
            }
            catch (NoSuchFieldException e)
            {
                //Field 涓嶅湪褰撳墠綾誨畾涔? 緇х畫鍚戜笂杞瀷
            }
        }
        return null;
    }
   
   
    public static Object invokeMethod(Object object, String methodName,
            Class<?>[] parameterTypes, Object[] parameters)
            throws InvocationTargetException
    {
        Method method = getDeclaredMethod(object, methodName, parameterTypes);
       
        if (method == null)
        {
            throw new IllegalArgumentException("Could not find method ["
                    + methodName + "] on target [" + object + "]");
        }
       
        method.setAccessible(true);
       
        try
        {
            return method.invoke(object, parameters);
        }
        catch (IllegalAccessException e)
        {
           
        }
       
        return null;
    }
   
   
    public static void setFieldValue(Object object, String fieldName,
            Object value)
    {
        Field field = getDeclaredField(object, fieldName);
       
        if (field == null)
            throw new IllegalArgumentException("Could not find field ["
                    + fieldName + "] on target [" + object + "]");
       
        makeAccessible(field);
       
        try
        {
            field.set(object, value);
        }
        catch (IllegalAccessException e)
        {
            e.printStackTrace();
        }
    }
   
   
    public static Object getFieldValue(Object object, String fieldName)
    {
        Field field = getDeclaredField(object, fieldName);
        if (field == null)
            throw new IllegalArgumentException("Could not find field ["
                    + fieldName + "] on target [" + object + "]");
       
        makeAccessible(field);
       
        Object result = null;
        try
        {
            result = field.get(object);
        }
        catch (IllegalAccessException e)
        {
            e.printStackTrace();
        }
       
        return result;
    }
   
}

5.鏇存柊mapper configuration鏂囦歡錛屾坊鍔犲涓嬪嚑鏉★紝娉ㄦ剰plugins鍦ㄦ暣涓猚onfiguration鏂囦歡涓殑欏哄簭

<plugins>
<plugin interceptor="functionPoint.db.DiclectStatementHandlerInterceptor"/>
<plugin interceptor="functionPoint.db.DiclectResultSetHandlerInterceptor"/>
</plugins>

6.浣跨敤鏂規(guī)硶鍚宮ybatis閫昏緫鍒嗛〉錛屾嫤鎴櫒浼氳嚜鍔ㄦ嫤鎴墽琛孲QL鐨勫湴鏂癸紝鍔犱笂鍒嗛〉浠g爜錛?/strong>

getSqlSession().selectList(mapId, queryKey,new RowBounds(pageId, pageSize));


==============================================================
鎸夌収涓婇潰鐨勫仛浜?浣嗛亱琛屾檪鍗繪媼鍑虹己灝?IN OUT鍙冩暩涔嬮鐨勯尟瑾?
寰屼締鎻涗簡Dialect欏炴枃浠跺氨O(jiān)K浜?OracleDialect鍏у鍙冭冭嚜:
http://rapid-framework.googlecode.com/svn/trunk/rapid-framework/src/rapid_framework_common/cn/org/rapid_framework/jdbc/dialect/




Ke 2011-08-03 17:15 鍙戣〃璇勮
]]>
瀛樺偍榪囩▼http://www.aygfsteel.com/keweibo/articles/306057.htmlKeKeTue, 15 Dec 2009 11:39:00 GMThttp://www.aygfsteel.com/keweibo/articles/306057.htmlhttp://www.aygfsteel.com/keweibo/comments/306057.htmlhttp://www.aygfsteel.com/keweibo/articles/306057.html#Feedback0http://www.aygfsteel.com/keweibo/comments/commentRss/306057.htmlhttp://www.aygfsteel.com/keweibo/services/trackbacks/306057.html <parameterMap id="swapParameters" class="map" >
<parameter property="email1" jdbcType="VARCHAR" javaType="java.lang.String" mode="INOUT"/>
<parameter property="email2" jdbcType="VARCHAR" javaType="java.lang.String" mode="INOUT"/>
</parameterMap>
<procedure id="swapEmailAddresses" parameterMap="swapParameters" >
{call swap_email_address (?, ?)}
</procedure>

Ke 2009-12-15 19:39 鍙戣〃璇勮
]]>
鑷姩鐢熸垚鐨勪富閿?/title><link>http://www.aygfsteel.com/keweibo/articles/306055.html</link><dc:creator>Ke</dc:creator><author>Ke</author><pubDate>Tue, 15 Dec 2009 11:37:00 GMT</pubDate><guid>http://www.aygfsteel.com/keweibo/articles/306055.html</guid><wfw:comment>http://www.aygfsteel.com/keweibo/comments/306055.html</wfw:comment><comments>http://www.aygfsteel.com/keweibo/articles/306055.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/keweibo/comments/commentRss/306055.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/keweibo/services/trackbacks/306055.html</trackback:ping><description><![CDATA[寰堝鏁版嵁搴撴敮鎸佽嚜鍔ㄧ敓鎴愪富閿殑鏁版嵁綾誨瀷銆備笉榪囪繖閫氬父錛堝茍涓嶆繪槸錛夋槸涓鏈夌殑鐗規(guī)с係QL Map閫氳繃<insert>鐨勫瓙鍏冪礌<selectKey>鏉ユ敮鎸佽嚜鍔ㄧ敓鎴愮殑閿箋傚畠鍚屾椂鏀寔棰勭敓鎴愶紙濡侽racle錛夊拰鍚庣敓鎴愪袱縐嶇被鍨嬶紙濡侻S-SQL Server錛夈備笅闈㈡槸涓や釜渚嬪瓙錛?br /> <<br /> !鈥擮racle SEQUENCE Example --><br /> <insert id="insertProduct-ORACLE" parameterClass="com.domain.Product"><br /> <selectKey resultClass="int" keyProperty="id" ><br /> SELECT STOCKIDSEQUENCE.NEXTVAL AS ID FROM DUAL<br /> </selectKey><br /> insert into PRODUCT (PRD_ID,PRD_DESCRIPTION)<br /> values (#id#,#description#)<br /> </insert><br /> <!鈥?Microsoft SQL Server IDENTITY Column Example --><br /> <insert id="insertProduct-MS-SQL" parameterClass="com.domain.Product"><br /> insert into PRODUCT (PRD_DESCRIPTION)<br /> values (#description#)<br /> <selectKey resultClass="int" keyProperty="id" ><br /> SELECT @@IDENTITY AS ID<br /> </selectKey><br /> </insert> <img src ="http://www.aygfsteel.com/keweibo/aggbug/306055.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/keweibo/" target="_blank">Ke</a> 2009-12-15 19:37 <a href="http://www.aygfsteel.com/keweibo/articles/306055.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item></channel></rss> <footer> <div class="friendship-link"> <a href="http://www.aygfsteel.com/" title="狠狠久久亚洲欧美专区_中文字幕亚洲综合久久202_国产精品亚洲第五区在线_日本免费网站视频">狠狠久久亚洲欧美专区_中文字幕亚洲综合久久202_国产精品亚洲第五区在线_日本免费网站视频</a> </div> </footer> 主站蜘蛛池模板: <a href="http://" target="_blank">大姚县</a>| <a href="http://" target="_blank">象州县</a>| <a href="http://" target="_blank">海安县</a>| <a href="http://" target="_blank">横峰县</a>| <a href="http://" target="_blank">东乡县</a>| <a href="http://" target="_blank">金溪县</a>| <a href="http://" target="_blank">彭阳县</a>| <a href="http://" target="_blank">天长市</a>| <a href="http://" target="_blank">郁南县</a>| <a href="http://" target="_blank">临夏县</a>| <a href="http://" target="_blank">藁城市</a>| <a href="http://" target="_blank">九江市</a>| <a href="http://" target="_blank">全椒县</a>| <a href="http://" target="_blank">孝感市</a>| <a href="http://" target="_blank">新乡市</a>| <a href="http://" target="_blank">龙南县</a>| <a href="http://" target="_blank">湘潭市</a>| <a href="http://" target="_blank">炎陵县</a>| <a href="http://" target="_blank">嘉祥县</a>| <a href="http://" target="_blank">常宁市</a>| <a href="http://" target="_blank">大安市</a>| <a href="http://" target="_blank">抚宁县</a>| <a href="http://" target="_blank">玛曲县</a>| <a href="http://" target="_blank">汝南县</a>| <a href="http://" target="_blank">句容市</a>| <a href="http://" target="_blank">博乐市</a>| <a href="http://" target="_blank">通城县</a>| <a href="http://" target="_blank">都安</a>| <a href="http://" target="_blank">福海县</a>| <a href="http://" target="_blank">德州市</a>| <a href="http://" target="_blank">商都县</a>| <a href="http://" target="_blank">平武县</a>| <a href="http://" target="_blank">邹城市</a>| <a href="http://" target="_blank">康乐县</a>| <a href="http://" target="_blank">来凤县</a>| <a href="http://" target="_blank">阿拉善右旗</a>| <a href="http://" target="_blank">宾阳县</a>| <a href="http://" target="_blank">贺州市</a>| <a href="http://" target="_blank">泽库县</a>| <a href="http://" target="_blank">张掖市</a>| <a href="http://" target="_blank">民勤县</a>| <script> (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })(); </script> </body>