`
df274119386
  • 浏览: 54214 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论
收藏列表
标题 标签 来源
spring mvc exception 1
package com.cnpay.common.util.exception;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.ConstraintViolationException;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.validator.engine.ConstraintViolationImpl;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.handler.SimpleMappingExceptionResolver;

/**
 * SpringMVC系统异常处理
 * @author ningzhirong
 *
 */
public class SystemExceptionHandler extends SimpleMappingExceptionResolver {

	private static final Log log = LogFactory.getLog(SystemExceptionHandler.class);
	
	@SuppressWarnings("rawtypes")
	@Override
    protected ModelAndView doResolveException(HttpServletRequest request,  
            HttpServletResponse response, Object handler, Exception ex) {
		String viewName = determineViewName(ex, request);
		//异常类型名称
		String exName = ex.getClass().getName();
		if(viewName != null){
			//jsp格式返回
			if (!((request.getHeader("accept") != null && request.getHeader("accept").indexOf("application/json") > -1) ||
					(request.getHeader("X-Requested-With") != null && request.getHeader("X-Requested-With").indexOf("XMLHttpRequest") > -1))) {
                // 如果不是异步请求 
                // Apply HTTP status code for error views, if specified.  
                // Only apply it if we're processing a top-level request.  
                Integer statusCode = determineStatusCode(request, viewName);  
                if (statusCode != null) {
                    applyStatusCodeIfPossible(request, response, statusCode);  
                }
//              log.error(ex);
                
				/**
				 * 请不要丢弃异常堆栈,也应该要记录日志!!!!!!
				 * @author lilinzong
				 */
				log.error(ex.getMessage(),ex);
				if(exName.endsWith("ConstraintViolationException")){
					ModelAndView view = getModelAndView("/../../view/validationException", ex, request);
					String msg = "数据校验错误:" + ((ConstraintViolationException)ex).getConstraintViolations().iterator().next().getMessage();
					view.addObject("msg", msg);
					return view; 
				} else {
					return getModelAndView(viewName, ex, request);  
				}
			}else{
				//json格式返回
				response.setContentType("application/json;charset=UTF-8");
				if(exName.endsWith("ConstraintViolationException")){
					Iterator its = ((ConstraintViolationException)ex).getConstraintViolations().iterator();
					Map<String, String> map = new HashMap<String, String>();
					ModelAndView model = new ModelAndView();
					if(its.hasNext()){
						Object obj = its.next();
						if(obj instanceof ConstraintViolationImpl){
							ConstraintViolationImpl cons = (ConstraintViolationImpl)obj;
							String message = cons.getMessageTemplate();
							map.put("msg", message);
							log.debug(">>>"+message);
							model.addObject("message",message);
							model.setViewName("/../../view/errorBean");
						}
					}
					return model;
				}else if(exName.endsWith("BaseException")){
					//自定义异常
//					log.error(ex.getMessage());
					
					/**
					 * 请不要丢弃异常堆栈,也应该要记录日志!!!!!!
					 * @author lilinzong
					 */
					log.error(ex.getMessage(),ex);
					
					return getModelAndView("/../../view/exceptionJson", ex, request);
				}else{
					//系统异常
//					log.error(ex);
					
					/**
					 * 请不要丢弃异常堆栈,也应该要记录日志!!!!!!
					 * @author lilinzong
					 */
					log.error(ex.getMessage(),ex);
					
					return getModelAndView("/../../view/errorJson", ex, request);
				}
			}
		}
		
		//请不要丢弃异常堆栈丢弃,也应该要记录日志!!!!!!	添加人:lilinzong
		log.error(ex.getMessage(),ex);
		
		return getModelAndView("/../../view/error", ex, request);
	}
}




package com.cnpay.common.util.exception;

public class SystemException extends RuntimeException {

	/** */
	private static final long serialVersionUID = -8628600186414692263L;

	public SystemException(String message, Throwable cause) {
		super(message, cause);
	}

	public SystemException(String message) {
		super(message);
	}

	public SystemException(Throwable cause) {
		super(cause);
	}

}



package com.cnpay.common.util.exception;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;


@Aspect
@Component("exceptionAspect")
public class ExceptionTraceAspect {
	
	@Pointcut("execution(* com.cnpay..*.*(..))")
	private void serviceCall() {
		System.out.println("serviceCall======================");
	}

	@AfterThrowing(pointcut = "serviceCall()", throwing = "ex")
	public void afterThrowing(JoinPoint point, Exception ex) {
		//TODO 当异常发送,返回默认错误0001(系统错误!,
        ex.printStackTrace();
		System.out.println("系统出现异常, throws Exception! " + ex.getClass());
	}
}



package com.cnpay.common.util.exception;

import org.apache.log4j.Logger;


/**
 *  
 *  
 *  类            名:     BaseException
 *  修 改 记 录:     // 修改历史记录,包括修改日期、修改者及修改内容
 *  版 权 所 有:     版权所有(C)2010-2014
 *  公             司:     深圳华夏通宝信息技术有限公司
 *  @version    V1.0
 *  @date       2014年11月7日
 *  @author     lilinzong
 *
 */
public class BaseException extends RuntimeException {
	private static final Logger logger = Logger.getLogger(BaseException.class);
	/** */
	private static final long serialVersionUID = -8628600186414692263L;

	public BaseException(String message, Throwable cause) {
		super(message, cause);
		logger.error(message);//add by panguixiang
	}

	public BaseException(String message) {
		super(message);
		logger.error(message);//add by panguixiang
	}

	public BaseException(Throwable cause) {
		super(cause);
	}
	public BaseException(String format, Throwable cause, Object... objects) {
		super(String.format(format, objects), cause);
	}
	public BaseException(String format, Object... objects) {
		super(String.format(format, objects));
	}
}




	<!-- 配置异常跳转 -->
	<bean id="exceptionResolver" class="com.cnpay.common.util.exception.SystemExceptionHandler">
		<property name="exceptionMappings">
			<props>
				<prop key="com.cnpay.common.util.exception.BaseException">/../../view/exception</prop>
				<prop key="java.lang.Exception">/../../view/error</prop>
			</props>
		</property>
	</bean>



翻墙应用
XSkyWalker
得好好研究下 表单验证 http://validform.rjboy.cn/
http://validform.rjboy.cn/
easyui 表单验证
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="renderer" content="webkit"> 
<title></title>
<link href="images/favicon.ico" type="image/x-icon" rel="shortcut icon" /> 
<link rel="bookmark" href="images/favicon.ico" type="image/x-icon" />
<link rel="stylesheet" type="text/css" href="bin/jquery-easyui-1.4.1/themes/metro/easyui.css">
<link rel="stylesheet" type="text/css" href="bin/jquery-easyui-1.4.1/themes/icon.css">
<style type="text/css">
.specCheck tr{border-bottom:1px dashed #ccc}
.specCheck td{padding:10px}
.specCheck .item{margin:5px}
.ui-btn1{margin:0 auto}
</style>
</head>
<body>
	<div class="main">
		<form id="addModel">
			<div class="clearfix">
				<a class="ui-btn2 f-right" href="onlineFinance/checkModel/manage">添加模型</a>
				<div class="f-left">
					<label>模型名称:</label><input type="text" required="true" name="modelName"  validType="QQ" class="easyui-validatebox" />
				</div>
			</div>
		</form>
			<input type="button" value="提交" onclick="addModel()"/>
	</div>
	
<script type="text/javascript" src="js/lib/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="js/lib/common.js"></script>
<script type="text/javascript" src="js/lib/doT.min.js"></script>
<script type="text/javascript" src="bin/jquery-easyui-1.4.1/jquery.easyui.min.js"></script>
<script type="text/javascript" src="bin/jquery-easyui-1.4.1/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript">
/**
 * 添加模型方法
 */
function addModel(){	
	
	if(!$("#addModel").form('validate')){
		return;
	}
	
	alert("表单验证通过, 提交成功!");
}


$.extend($.fn.validatebox.defaults.rules, {
    CHS: {
        validator: function (value, param) {
            return /^[\u0391-\uFFE5]+$/.test(value);
        },
        message: '请输入汉字'
    },
    ZIP: {
        validator: function (value, param) {
            return /^[1-9]\d{5}$/.test(value);
        },
        message: '邮政编码不存在'
    },
    QQ: {
        validator: function (value, param) {
            return /^[1-9]\d{4,10}$/.test(value);
        },
        message: 'QQ号码不正确'
    },
    mobile: {
        validator: function (value, param) {
            return /^((\(\d{2,3}\))|(\d{3}\-))?13\d{9}$/.test(value);
        },
        message: '手机号码不正确'
    },
    loginName: {
        validator: function (value, param) {
            return /^[\u0391-\uFFE5\w]+$/.test(value);
        },
        message: '登录名称只允许汉字、英文字母、数字及下划线。'
    },
    safepass: {
        validator: function (value, param) {
            return safePassword(value);
        },
        message: '密码由字母和数字组成,至少6位'
    },
    equalTo: {
        validator: function (value, param) {
            return value == $(param[0]).val();
        },
        message: '两次输入的字符不一至'
    },
    number: {
        validator: function (value, param) {
            return /^\d+$/.test(value);
        },
        message: '请输入数字'
    },
    idcard: {
        validator: function (value, param) {
            return idCard(value);
        },
        message:'请输入正确的身份证号码'
    },
    checkModelName:{//ajax检查
	        validator: function (value, param) {  
	            var checkR=false;  
	            $.ajax({  
	                async : false,    
	                type : 'post',    
	                url : 'riskControl/creditrate/checkModelName',    
	                data : {    
	                    modelName : value  
	                },    
	                success : function(result) {    
	                    if (result === 'true') {    
	                        checkR= true;    
	                    }    
	                }    
	            });    
	            return checkR;   
	        },  
	        message: '请输入正确的模型名称,'  
    }  

});

/* 密码由字母和数字组成,至少6位 */
var safePassword = function (value) {
    return !(/^(([A-Z]*|[a-z]*|\d*|[-_\~!@#\$%\^&\*\.\(\)\[\]\{\}<>\?\\\/\'\"]*)|.{0,5})$|\s/.test(value));
}

var idCard = function (value) {
    if (value.length == 18 && 18 != value.length) return false;
    var number = value.toLowerCase();
    var d, sum = 0, v = '10x98765432', w = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2], a = '11,12,13,14,15,21,22,23,31,32,33,34,35,36,37,41,42,43,44,45,46,50,51,52,53,54,61,62,63,64,65,71,81,82,91';
    var re = number.match(/^(\d{2})\d{4}(((\d{2})(\d{2})(\d{2})(\d{3}))|((\d{4})(\d{2})(\d{2})(\d{3}[x\d])))$/);
    if (re == null || a.indexOf(re[1]) < 0) return false;
    if (re[2].length == 9) {
        number = number.substr(0, 6) + '19' + number.substr(6);
        d = ['19' + re[4], re[5], re[6]].join('-');
    } else d = [re[9], re[10], re[11]].join('-');
    if (!isDateTime.call(d, 'yyyy-MM-dd')) return false;
    for (var i = 0; i < 17; i++) sum += number.charAt(i) * w[i];
    return (re[2].length == 9 || number.charAt(17) == v.charAt(sum % 11));
}

var isDateTime = function (format, reObj) {
    format = format || 'yyyy-MM-dd';
    var input = this, o = {}, d = new Date();
    var f1 = format.split(/[^a-z]+/gi), f2 = input.split(/\D+/g), f3 = format.split(/[a-z]+/gi), f4 = input.split(/\d+/g);
    var len = f1.length, len1 = f3.length;
    if (len != f2.length || len1 != f4.length) return false;
    for (var i = 0; i < len1; i++) if (f3[i] != f4[i]) return false;
    for (var i = 0; i < len; i++) o[f1[i]] = f2[i];
    o.yyyy = s(o.yyyy, o.yy, d.getFullYear(), 9999, 4);
    o.MM = s(o.MM, o.M, d.getMonth() + 1, 12);
    o.dd = s(o.dd, o.d, d.getDate(), 31);
    o.hh = s(o.hh, o.h, d.getHours(), 24);
    o.mm = s(o.mm, o.m, d.getMinutes());
    o.ss = s(o.ss, o.s, d.getSeconds());
    o.ms = s(o.ms, o.ms, d.getMilliseconds(), 999, 3);
    if (o.yyyy + o.MM + o.dd + o.hh + o.mm + o.ss + o.ms < 0) return false;
    if (o.yyyy < 100) o.yyyy += (o.yyyy > 30 ? 1900 : 2000);
    d = new Date(o.yyyy, o.MM - 1, o.dd, o.hh, o.mm, o.ss, o.ms);
    var reVal = d.getFullYear() == o.yyyy && d.getMonth() + 1 == o.MM && d.getDate() == o.dd && d.getHours() == o.hh && d.getMinutes() == o.mm && d.getSeconds() == o.ss && d.getMilliseconds() == o.ms;
    return reVal && reObj ? d : reVal;
    function s(s1, s2, s3, s4, s5) {
        s4 = s4 || 60, s5 = s5 || 2;
        var reVal = s3;
        if (s1 != undefined && s1 != '' || !isNaN(s1)) reVal = s1 * 1;
        if (s2 != undefined && s2 != '' && !isNaN(s2)) reVal = s2 * 1;
        return (reVal == s1 && s1.length != s5 || reVal > s4) ? -10000 : reVal;
    }
};

</script>
</body>
</html>
Oracle 用一个表字段更新另一个表字段三种方法 http://blog.sina.com.cn/s/blog_6e5d06ec0100x5ov.html

1. update (select .....) set column1 = column2;

update (select iy.company_name company_name1, cc.company_name_jc company_name2
        from income_year_item iy , city_company cc

       where iy.company_code = cc.code
       )
   set company_name1 = company_name2;

2.只能单行子查询s

update  CITY_PROJECT_SCALE_INFO c  set
(c.value) = (
       select d.value from CITY_PROJECT_SCALE_INFO @test d where d.project_id = '7d7fd580a06240b2a9137dc2bbe831e9'
          and d.project_id = c.project_id and c.company_code = d.company_code
)
 where exists (
  select 1 from  CITY_PROJECT_SCALE_INFO @test d where d.project_id = '7d7fd580a06240b2a9137dc2bbe831e9'
          and d.project_id = c.project_id and c.company_code = d.company_code
)

3.使用merg inot 语句

--更新生产基础字段
merge into city_cfg_data_column_common cf1 using
      city_cfg_data_column_common2 cf2 on
      (cf1.resourceid = cf2.resourceid)
   when matched then
        update set   cf1.template_type = cf2.template_type,
                     cf1.chinese_name = cf2.chinese_name,
                     cf1.column_name = cf2.column_name,
                     cf1.column_type = cf2.column_type,
                     cf1.column_size = cf2.column_size
  when not matched then
       insert (cf1.resourceid,cf1.template_type,cf1.chinese_name,cf1.column_name,cf1.column_type,cf1.column_size
              ,cf1.is_can_edit,cf1.is_unique,cf1.is_can_cover,cf1.show_order)
       values (cf2.resourceid,cf2.template_type,cf2.chinese_name,cf2.column_name,cf2.column_type,cf2.column_size
              ,cf2.is_can_edit,cf2.is_unique,cf2.is_can_cover,cf2.show_order)
spring aop 方法过滤器
/**处理方法权限*/
package com.cnpay.smf.system.common.interceptor;

import java.lang.reflect.Method;
import java.util.List;

import org.apache.commons.lang3.StringUtils;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Service;


@Service
public class MethodFilter {

	@Autowired
	private CommonDao commonDao;

	/**
	 * 方法之前执行
	 * @param pjp
	 * @return
	 * @throws Throwable
	 */
	public Object doMethodBefore(ProceedingJoinPoint pjp) throws Throwable {
		Method method = ((MethodSignature) pjp.getSignature()).getMethod();
		MethodCode mc = method.getAnnotation(MethodCode.class);
		if (mc != null && !StringUtils.isBlank(mc.name()) && !findMethodCode(mc.name())) {
			throw new BaseException("您没有权限执行此操作");
		}
		return pjp.proceed();
	}

	@SuppressWarnings("unchecked")
	private boolean findMethodCode(String code) {
		List<SystLogonResource> list = (List<SystLogonResource>) commonDao.queryList(
						"from SystLogonResource lr where lr.method=? and lr.resourceType=? and lr.id in" +
						"(select resource.id from SystRoleResource where role.id=?) and lr.status=?",
						code, SystLogonResource.RESOURCE_TYPE_BUTTOM, UserUtil.getRoleId(),SystLogonResource.STATUS_ENABLED);
		if (list != null && list.size() > 0) {
			return true;
		}
		return false;
	}

}
hibernate BaseDAOImpl
@Repository("baseDao")
public class BaseDaoImpl<T, PK extends Serializable> implements BaseDao<T, PK> {

	private static final Logger LOG = LoggerFactory.getLogger(BaseDaoImpl.class);

	/**
	 * SessionFactory
	 */
	private SessionFactory sessionFactory;

	/**
	 * HibernateTemplate
	 */
	private HibernateTemplate hibernateTemplate;

	/**
	 * 注入 HibernateTemplate
	 * @param hibernateTemplate
	 */
	@Resource(name = "hibernateTemplate")
	protected void setHibernateTemplate(HibernateTemplate hibernateTemplate) {
		this.hibernateTemplate = hibernateTemplate;
	}

	/**
	 * 注入SessionFactory
	 * @param sessionFactory
	 */
	@Resource(name = "sessionFactory")
	public void setSessionFactory(SessionFactory sessionFactory) {
		this.sessionFactory = sessionFactory;
	}

	/**
	 * 获取HibernateTemplate
	 * @param sessionFactory
	 */
	public HibernateTemplate getHibernateTemplate() {
		return hibernateTemplate;
	}

	/**
	 * 获取SessionFactory
	 * @param sessionFactory
	 */
	public SessionFactory getSessionFactory() {
		return sessionFactory;
	}

	/**
	 * Timeout waiting for idle object
	 * 
	 * @author Monster
	 * @return
	 */
	public Session getSession() {
		return sessionFactory.getCurrentSession();
	}

	/**
	 * 根据hql,返回Query
	 * 
	 * @author Monster
	 * @param hql
	 * @return
	 */
	public Query getQuery(final String hql) {
		return this.getSession().createQuery(hql);
	}

	/**
	 * 根据sql,返回Query
	 * 
	 * @author Monster
	 * @param hql
	 * @return
	 */
	public Query getSqlQuery(final String sql) {
		return this.getSession().createSQLQuery(sql);
	}

	/**
	 * 根据Hql和查询参数,返回<T>类型
	 * 
	 * @param hql
	 *            hql语句
	 * @param o
	 * @return
	 * @since 1.1
	 */
	@SuppressWarnings("unchecked")
	public T getList(final String hql, final Object... o) {
		return this.hibernateTemplate.execute(new HibernateCallback<T>() {
			@Override
			public T doInHibernate(Session session) throws HibernateException, SQLException {
				Query query = session.createQuery(hql);
				setQueryParams(query, o);
				return (T) query.list();
			}
		});
	}

	/**
	 * 根据sql,返回List<Object>
	 * 
	 * @param hql
	 *            hql语句
	 * @return
	 * @since 1.1
	 */
	@SuppressWarnings({ "unchecked", "rawtypes", "deprecation" })
	public List<Object> getSqlList(final String sql) {
		List<Object> list = this.hibernateTemplate.executeFind(new HibernateCallback() {
			public Object doInHibernate(Session session) throws HibernateException, SQLException {
				Query q = session.createSQLQuery(sql);
				return q.list();
			}
		});
		return list;
	}

	/**
	 * 根据hql和参数,返回List
	 * 
	 * @param hql
	 *            hql语句
	 * @param o
	 * @return
	 */
	public List<?> queryList(final String hql, final Object... o) {
		try {
			Query query = getQuery(hql);
			return setQueryParams(query, o).list();
		} catch (Exception e) {
			throw e;
		}
	}
	
	public void queryPage(DetachedCriteria detachedCriteria, Page page) {
		Criteria criteria = detachedCriteria.getExecutableCriteria(getSession());
		Long count = (Long) criteria.setProjection(Projections.rowCount()).uniqueResult();
		if (null != count) {
			page.setTotalProperty(count.intValue());
		}
		LOG.debug("COUNT:" + count + " | PAGE > START:" + page.getStart() + " | LIMIT:" + page.getLimit());
		criteria.setProjection(null);
		criteria.setResultTransformer(CriteriaSpecification.ROOT_ENTITY);
		page.setRoot(criteria.setFirstResult(page.getStart()).setMaxResults(page.getLimit()).list());
	}

	public void queryPage(Page page, List<?> list, int size) {
		if (list != null && list.size() > 0) {
			page.setTotalProperty(size);
			LOG.debug("COUNT:" + size + " | PAGE > START:" + page.getStart() + " | LIMIT:" + page.getLimit());
			page.setRoot(list);
		}
	}

	/**
	 * 获取总记录数
	 * 
	 * @author Monster
	 * @param query
	 * @param parameters
	 */
	public Long getCountSize(Class<?> clazz) {
		try {
			String hql = "select count(*) from " + clazz.getSimpleName();
			return ((Long) getQuery(hql).iterate().next()).longValue();
		} catch (Exception e) {
			throw e;
		}
	}
	
	/**
	 * 获取总记录数
	 * 
	 * @author Monster
	 * @param query
	 * @param parameters
	 */
	public Long getCountSize(Class<?> clazz, String id) {
		try {
			String hql = "select count(*) from " + clazz.getSimpleName() + " where 1 = 1 and id = ? ";
			Query query = getQuery(hql);
			query.setParameter(0, id);
			return ((Long)query.iterate().next()).longValue();
		} catch (Exception e) {
			throw e;
		}
	}

	/**
	 * 带分页的hql查询
	 * 
	 * @param hql
	 * @param first
	 * @param limit
	 * @param o
	 *            HQL的参数
	 * @return
	 */
	public List<?> getHqlList(final String hql, int first, int limit, final Object... o) {
		try {
			Query query = getQuery(hql);
			return setQueryParams(query, o).setFirstResult(first).setMaxResults(limit).list();
		} catch (Exception e) {
			throw e;
		}
	}

	/**
	 * 分页查询语句 返回List查询
	 * 
	 * @param hql
	 *            hql语句
	 * @param first
	 * @param limit
	 * @param o
	 * @return {@link List}
	 */
	public List<?> queryListPage(final String hql, int first, int limit, final Object... o) {
		try {
			Query query = getQuery(hql);
			return setQueryParams(query, o).setFirstResult(first).setMaxResults(limit).list();
		} catch (Exception e) {
			throw e;
		}
	}

	/**
	 * 查询
	 * 
	 * @author Monster
	 * @param query
	 * @param parameters
	 */
	@SuppressWarnings("unchecked")
	public <E> E getList(Query query, BasicReq req) {
		try {
			return (E) query.setFirstResult((req.getPage() - 1) * req.getRows()).setMaxResults(req.getRows()).list();
		} catch (Exception e) {
			throw e;
		}
	}
	
	/**
	 * 查询
	 * 
	 * @author Monster
	 * @param query
	 * @param parameters
	 */
	@SuppressWarnings("unchecked")
	public <E> E getList(Query query, PageJQGrid page) {
		try {
			Integer pageSize = Integer.parseInt(String.valueOf(page.getRows()));
			return (E) query.setFirstResult((page.getPage() - 1) * pageSize)
					.setMaxResults(pageSize).list();
		} catch (Exception e) {
			throw e;
		}
	}
	
	/**
	 * 查询加条件
	 * 
	 * @author Monster
	 * @param query
	 * @param o
	 * @return 
	 */
	@SuppressWarnings("unchecked")
	protected <E> E getList(Query query, PageJQGrid page, Object[] o) {
		try {
			setQueryParams(query, o);
			Integer pageSize = Integer.parseInt(String.valueOf(page.getRows()));
			return (E) query.setFirstResult((page.getPage() - 1) * pageSize)
					.setMaxResults(pageSize).list();
		} catch (Exception e) {
			throw e;
		}
	}

	/**
	 * 查询加条件
	 * 
	 * @author Monster
	 * @param query
	 * @param o
	 */
	@SuppressWarnings("unchecked")
	public <E> E getList(Query query, BasicReq req, Object[] o) {
		try {
			setQueryParams(query, o);
			return (E) query.setFirstResult((req.getPage() - 1) * req.getRows()).setMaxResults(req.getRows()).list();
		} catch (Exception e) {
			throw e;
		}
	}
	

	

	/**
	 * 查询加条件
	 * 
	 * @author Monster
	 * @param query
	 * @param o
	 */
	@SuppressWarnings("unchecked")
	public <E> E getList(Query query, Object[] o) {
		try {
			setQueryParams(query, o);
			return (E) query.list();
		} catch (Exception e) {
			throw e;
		}
	}

	public void addEntity(Object object) {
		try {
			this.hibernateTemplate.save(object);
		} catch (Exception e) {
			throw e;
		}
	}

	public void saveOrUpdateEntity(Object object) {
		try {
			this.hibernateTemplate.saveOrUpdate(object);
		} catch (Exception e) {
			throw e;
		}
	}

	@SuppressWarnings("unchecked")
	public T merge(Object obj, Class<T> clazz) {
		try {
			return (T) this.hibernateTemplate.merge(obj);
		} catch (Exception e) {
			throw e;
		}
	}
	

	public T merge(T t) {
		try {
			return (T) this.hibernateTemplate.merge(t);
		} catch (Exception e) {
			throw e;
		}
	}
	
	/**
	 * 保存或修改 
	 * 
	 * @param base
	 */
	public Base merge(Base base){
		try {
			return (Base) this.hibernateTemplate.merge(base);
		} catch (Exception e) {
			throw e;
		}
	}

	public void batchAddEntity(Collection<?> entities) {
		try {
			this.hibernateTemplate.saveOrUpdateAll(entities);
		} catch (Exception e) {
			throw e;
		}
	}

	public List<?> getListForCriteria(DetachedCriteria criteria) {
		return criteria.getExecutableCriteria(getSession()).list();
	}
	
	public List<?> getListForCriteria(DetachedCriteria criteria, int fetchRow) {
		return criteria.getExecutableCriteria(getSession()).setFirstResult(0).setMaxResults(fetchRow).list();
	}

	public void executeByNativeSql(String sql, Object... o) {
		try {
			Query query = getSqlQuery(sql);
			setQueryParams(query, o).executeUpdate();
		} catch (Exception e) {
			throw e;
		}
	}

	public void exeByNativeSql(String sql, Object[] o) {
		try {
			Query query = getSqlQuery(sql);
			setQueryParams(query, o).executeUpdate();
		} catch (Exception e) {
			throw e;
		}
	}

	public List<?> getListByNativeSql(String sql, Object... o) {
		try {
			Query query = getSqlQuery(sql);
			return setQueryParams(query, o).list();
		} catch (Exception e) {
			throw e;
		}
	}

	/**
	 * 不带参数为设置为NULL
	 *
	 */
	public void updateEntity(Object object) {
		try {
			this.hibernateTemplate.update(object);
		} catch (Exception e) {
			throw e;
		}

	}

	public Object get(Class<?> clazz, Serializable id) {
		return getSession().get(clazz, id);
	}

	public Object load(Class<?> clazz, Serializable id) {
		return getSession().load(clazz, id);
	}

	@SuppressWarnings("unchecked")
	public T getT(Class<T> clazz, Serializable id) {
		return (T) getSession().get(clazz, id);
	}

	public List<?> findList(String hql) {
		return this.hibernateTemplate.find(hql);
	}

	public void deleteEntity(Object object) {
		this.hibernateTemplate.delete(object);
	}

	public void deleteByProperty(Class<?> clazz, String property, Object object) {
		String hql = "delete " + clazz.getName() + " d where d." + property + "=?";
		this.executeUpdate(hql, new Object[] { object });

	}

	public Object findFirst(DetachedCriteria detachedCriteria) {
		Criteria criteria = detachedCriteria.getExecutableCriteria(getSession());
		List<?> list = criteria.setFirstResult(0).setMaxResults(1).list();
		if (list == null || list.size() == 0) {
			return null;
		}
		return list.get(0);
	}

	@SuppressWarnings("unchecked")
	public Object findFirst(String hql, Object... values) {
		List<Object> list = this.hibernateTemplate.find(hql, values);
		if (list == null || list.size() == 0) {
			return null;
		}
		return list.get(0);
	}

	public void deleteAll(Collection<?> entities) {
		this.hibernateTemplate.deleteAll(entities);
	}

	/**
	 * 统计数量
	 */
	public Long getCount(DetachedCriteria criteria) {
		Criteria c = criteria.getExecutableCriteria(getSession());
		return (Long) c.setProjection(Projections.rowCount()).uniqueResult();
	}

	/**
	 * 最大值
	 */
	public Object getMax(DetachedCriteria criteria, String propertyName) {
		Criteria c = criteria.getExecutableCriteria(getSession());
		return c.setProjection(Projections.max(propertyName)).uniqueResult();
	}

	/**
	 * 总计
	 */
	public Object getSumByProperty(DetachedCriteria criteria, String propertyName) {
		Criteria c = criteria.getExecutableCriteria(getSession());
		return c.setProjection(Projections.sum(propertyName)).uniqueResult();
	}

	public int countOfHql(String hql, Object... o) {
		Query query = getQuery(hql);
		return ((Long) setQueryParams(query, o).uniqueResult()).intValue();
	}

	public Object countOfSql(String sql, Object... o) {
		Query query = getSqlQuery(sql);
		return setQueryParams(query, o).uniqueResult();
	}

	/**
	 * 设置参数(带map)
	 * 
	 * @param query
	 * @param map
	 * @return
	 */
	private Query setParameter(Query query, Map<String, Object> map) {
		if (map == null) {
			throw new NullPointerException("map参数为空!");
		}
		Set<String> keySet = map.keySet();
		for (String key : keySet) {
			Object obj = map.get(key);
			if (obj instanceof Collection<?>) {// 这里考虑传入的参数是什么类型,不同类型使用的方法不同
				query.setParameterList(key, (Collection<?>) obj);
			} else if (obj instanceof Object[]) {
				query.setParameterList(key, (Object[]) obj);
			} else {
				query.setParameter(key, obj);
			}
		}
		return query;
	}

	/**
	 * 设置参数
	 * 
	 * @author Monster
	 * @param query
	 * @param o
	 */
	public Query setQueryParams(Query query, Object[] o) {
		// if(o == null){
		// throw new NullPointerException("设置参数为空!");
		// }
		if (o != null && o.length > 0) {
			for (int i = 0; i < o.length; i++) {
				query.setParameter(i, o[i]);
			}
		}
		return query;
	}
	
	/**
	 * 设置参数,Map
	 * 
	 * @author Monster
	 * @param query
	 * @param o
	 */
	public Query setQueryParams(Query query, BaseParameters parameters) {
		Map<String, Object> map = parameters.getAll();
		if (map != null && map.size() > 0) {
			Set<String> keySet = map.keySet();
			for (String s : keySet) {
				query.setParameter(parameters.removeSymbol(s), map.get(s));
			}
		}
		return query;
	}
	

	/**
	 * 根据hql和参数,执行更新
	 */
	public int executeUpdate(String hql, Object... o) {
		try {
			Query query = getQuery(hql);
			return setQueryParams(query, o).executeUpdate();
		} catch (Exception e) {
			throw e;
		}
	}

	/**
	 * 根据hql和map参数,执行更新
	 * 
	 * @return
	 */
	public int executeUpdate(String hql, Map<String, Object> map) {
		try {
			Query query = getQuery(hql);
			return setParameter(query, map).executeUpdate();
		} catch (Exception e) {
			throw e;
		}
	}

	/**
	 * 关闭Connection, CallableStatement
	 * 
	 * @param conn
	 * @param call
	 */
	protected void closeStatement(Connection conn, CallableStatement call) {
		try {
			if (call != null) {
				call.close();
			}
			if (conn != null) {
				conn.close();
			}
		} catch (SQLException e) {
			throw new RuntimeException("关闭错误!");
		}
	}

	/**
	 * 强制同步数据到数据库
	 */
	public void flush() {
		this.hibernateTemplate.flush();
	}
	
	/**
	 * 强制清除session缓存 
	 */
	public void clear() {
		this.hibernateTemplate.clear();
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<T> getNamedHql(String hql, Map<String, Object> params) {
		Query query = getQuery(hql);
		if (null != params) {
			query.setProperties(params);
		}
		return query.list();
	}

	
	
	/**
	 * 
	 * @author yang
	 * @return
	 */
	
	private Class<T> clazz;
	

	public Class<T> getClazz() {
		return clazz;
	}

	public void setClazz(Class<T> clazz) {
		this.clazz = clazz;
	}

	/**
	 * 获取T,没有找到,返回null
	 */
	@Override
	public T getInfo(PK pk) {
		return (T) this.getHibernateTemplate().get(clazz, pk);
	}
	
	/**
	 * 获取T,没有找到,返回null
	 */
	@Override
	public T getInfo(Class<T> clazz, PK pk) {
		return (T) this.getHibernateTemplate().get(clazz, pk);
	}
	
	
	/**
	 * 获取T,没有找到,返回null
	 */
	@Override
	public Base getInfo(PK pk, Class<T> clazz) {
		return (Base) this.getHibernateTemplate().get(clazz, pk);
	}
	
	/**
	 * 获取T,返回代理对象
	 */
	@Override
	public T loadInfo(PK pk) {
		return (T) this.getHibernateTemplate().load(clazz, pk);
	}

	/**
	 * 返回总记录数
	 */
	@Override
	public int getTotalRecord(final DetachedCriteria dc) {
		Integer count = 0;
		if (dc != null) {
			count = getHibernateTemplate().execute(
					new HibernateCallback<Integer>() {
						@SuppressWarnings("rawtypes")
						public Integer doInHibernate(Session session)
								throws HibernateException {
							Criteria criteria = dc.getExecutableCriteria(session);
							CriteriaImpl impl = (CriteriaImpl) criteria;
							Projection projection = impl.getProjection();// 取出projection
							List orderEntries = new ArrayList();// 用来存放排序字段
							Field field = null;
							Long count = 0L;
							try {
								field = CriteriaImpl.class
										.getDeclaredField("orderEntries");
								field.setAccessible(true);
								orderEntries = (List) field.get(impl);// 将对象中的排序字段存入数组中
								field.set(criteria, new ArrayList());// 将排序字段设置为空

								count = (Long) criteria.setProjection(
										Projections.rowCount()).uniqueResult();

								criteria.setProjection(projection);// 重新设置回projection
								if (projection == null)
									criteria
											.setResultTransformer(CriteriaSpecification.ROOT_ENTITY);
								field.set(criteria, orderEntries);// 重新设置回排序字段
							} catch (Exception e) {
								e.printStackTrace();
							}
							if (count == null) return 0;
							return count.intValue();
						}
					});
		}
		return count.intValue();
	}

	@Override
	@Deprecated
	public List<? extends Object> getList(String[] paramNames,
			String[] paramValues) {
		return null;
	}

	@Override
	@Deprecated
	public List<? extends Object> getRows(String[] paramNames,
			String[] paramValues) {
		return null;
	}

	/**
	 * 分页查询数据
	 */
	@Override
	public List<T> findByCriteria(final DetachedCriteria dc, final Integer firstResult, final Integer maxResults) {
		try {
			return getHibernateTemplate().execute(new HibernateCallback<List<T>>() {
				@SuppressWarnings("unchecked")
				public List<T> doInHibernate(Session session)
						throws HibernateException {
					Criteria criteria = dc.getExecutableCriteria(session);
					List<T> list = null;
					/*if (firstResult == null || maxResults == null || firstResult == 0 || maxResults == 0) {
						throw new BaseException("没有设置分页参数!");
					} else {*/
						list = criteria.setFirstResult(firstResult).setMaxResults(maxResults).list();
					/*}*/
					//criteria.setFirstResult(0).setMaxResults(10);// 这里必须重新设置一次,否下次调用时会出错,至于什么原因我也还没有弄清楚,希望搞定的朋友能回复一下
					return list;
				}
			});
		} catch (Exception e) {
			throw e;
		}

	}

	/**
	 * 删除
	 */
	@Override
	public void removeInfo(PK pk) {
		try {
			this.getHibernateTemplate().delete(getInfo(pk));
		} catch (Exception e) {
			throw e;
		}
	}

	/**
	 * 保存
	 * 返回id
	 */
	@Override
	public Serializable saveInfo(T t) {
		try {
			return this.getHibernateTemplate().save(t);
		} catch (Exception e) {
			throw e;
		}
	}
	
	/**
	 * 保存
	 * @param object
	 * @return
	 */
	public Serializable save(Object object){
		try {
			return this.getHibernateTemplate().save(object);
		} catch (Exception e) {
			throw e;
		}
	}
	
	/**
	 * 比较数据,保存或更新
	 */
	@Override
	public T mergeInfo(T t) {
		try{
			return this.getHibernateTemplate().merge(t);
		} catch (Exception e) {
			throw e;
		}
	}

	/**
	 * 更新
	 */
	@Override
	public void updateInfo(T t) {
		try{
			this.getHibernateTemplate().update(t);
		} catch (Exception e) {
			throw e;
		}
	}
	
	/**
	 * 更新
	 */
	@Override
	public void updateInfo(Base b) {
		try{
			this.getHibernateTemplate().update(b);
		} catch (Exception e) {
			throw e;
		}
	}

	/**
	 * Grid 分页查询
	 */
	@Override
	public List<T> findByPageGrid(PageGrid page) {
		final Integer firstResult = page.getFirstResult();
		final Integer maxResults = page.getMaxResults();
		final DetachedCriteria dc = page.getDc();
		try {
			return getHibernateTemplate().execute(new HibernateCallback<List<T>>() {
				@SuppressWarnings("unchecked")
				public List<T> doInHibernate(Session session)
						throws HibernateException {
					Criteria criteria = dc.getExecutableCriteria(session);
					List<T> list  = criteria.setFirstResult(firstResult).setMaxResults(maxResults).list();
					return list;
				}
			});
		} catch (Exception e) {
			throw e;
		}
	}

	/**
	 * 条件查询对象
	 * @param vo
	 * @return
	 */
	@SuppressWarnings("unchecked")
	@Override
	public T getInfo(BaseParameters parameters) {
		String hql = parameters.toString();
		Query query = getQuery(hql);
		setQueryParams(query, parameters);
		List<T> list = query.list();
		if(list != null && list.size() >= 1){
			return (T)list.get(0);
		}
		return null;
	}
	
	/**
	 * 条件查询对象
	 * @param vo
	 * @return
	 */
	@SuppressWarnings("unchecked")
	@Override
	public T getInfo(final DetachedCriteria dc) {
		List<T> list = null;
		try {
			list = getHibernateTemplate().execute(new HibernateCallback<List<T>>() {
				public List<T> doInHibernate(Session session)
						throws HibernateException {
					Criteria criteria = dc.getExecutableCriteria(session);
					List<T> list  = criteria.list();
					return list;
				}
			});
		} catch (Exception e) {
			throw e;
		}
		if(list != null && list.size() >= 0){
			return list.get(0);
		}
		return null;
	}
	
	/**
	 * 根据参数, 查询对象集合
	 * @param vo
	 * @return
	 */
	@SuppressWarnings("unchecked")
	@Override
	public List<T> getInfoList(BaseParameters parameters) {
		String hql = parameters.toString();
		Query query = getQuery(hql);
		setQueryParams(query, parameters);
		List<T> list = query.list();
		return list;
	}
	
	
}
hibernate BaseDAO
public interface BaseDao<T, PK extends Serializable> {

	/**
	 * 强制同步数据到数据库
	 */
	public void flush();
	
	/**
	 * 强制清除session缓存 
	 */
	public void clear();

	/**
	 * 执行HQL语句 增,改,删
	 * 
	 * @param hql
	 * @param params
	 * @return
	 */
	public int executeUpdate(String hql, Object... params);

	/**
	 * 共用分页查询
	 * 
	 * @param detachedCriteria
	 * @param page
	 * @return
	 */
	public void queryPage(DetachedCriteria detachedCriteria, Page page);


	/**
	 * 查询分页
	 * @param page
	 * @param list
	 * @param size
	 */
	public void queryPage(Page page, List<?> list, int size);

	/**
	 * 条件查询COUNT(*)
	 * 
	 * @param criteria
	 * @return
	 */
	public Long getCount(DetachedCriteria criteria);

	/**
	 * 条件查询COUNT(*)
	 * 
	 * @author Monster
	 * @param clazz
	 * @return
	 */
	public Long getCountSize(Class<?> clazz);

	/**
	 * 条件查询指定字段的最大值
	 * 
	 * @param criteria
	 * @param propertyName
	 * @return
	 */
	public Object getMax(DetachedCriteria criteria, String propertyName);

	/**
	 * 保存实体
	 * 
	 * @param object
	 */
	public void addEntity(Object object);

	/**
	 * 保存或修改
	 * 
	 * @param object
	 */
	public void saveOrUpdateEntity(Object object);


	/**
	 * 保存或修改
	 * @param obj
	 * @param clazz
	 * @return
	 */
	public T merge(Object obj, Class<T> clazz);

	/**
	 * 保存或修改
	 * 
	 * @param t
	 */
	public T merge(T t);
	
	/**
	 * 保存或修改 
	 * 
	 * @param base
	 */
	public Base merge(Base base);

	/**
	 * 批量保存实体
	 * 
	 * @param entities
	 */
	public void batchAddEntity(Collection<?> entities);

	/**
	 * 修改实体
	 * 
	 * @param object
	 */
	public void updateEntity(Object object);

	/**
	 * 条件查询数据
	 * 
	 * @param criteria
	 * @return
	 */
	public List<?> getListForCriteria(DetachedCriteria criteria);
	
	/**
	 * 条件查询数据,获取指定条数
	 * 
	 * @param criteria
	 * @param fetchRow
	 * @return
	 */
	public List<?> getListForCriteria(DetachedCriteria criteria, int fetchRow);

	/**
	 * 执行原生SQL
	 * 
	 * @param sql
	 * @param params
	 */
	public void executeByNativeSql(String sql, Object... params);

	/**
	 * 执行原生SQL
	 * 
	 * @param sql
	 * @param params
	 */
	public void exeByNativeSql(String sql, Object[] params);

	/**
	 * 查询对象
	 * 
	 * @param clazz
	 * @param id
	 * @return
	 */
	public Object get(Class<?> clazz, Serializable id);

	/**
	 * 查询对象,返回代理
	 * 
	 * @param clazz
	 * @param id
	 * @return
	 */
	public Object load(Class<?> clazz, Serializable id);

	/**
	 * 查询对象<T>
	 * 
	 * @param clazz
	 * @param id
	 * @return
	 */
	public T getT(Class<T> clazz, Serializable id);

	/**
	 * 删除对象
	 * 
	 * @param object
	 */
	public void deleteEntity(Object object);

	/**
	 * 通过属性删除
	 * 
	 * @param clazz
	 * @param property
	 * @param object
	 */
	public void deleteByProperty(Class<?> clazz, String property, Object object);

	/**
	 * 条件查询<br/>
	 * 只返回第一个对象
	 * 
	 * @param dc
	 * @return
	 */
	public Object findFirst(DetachedCriteria dc);

	/**
	 * 条件查询 只返回一个对象
	 * 
	 * @param hql
	 * @param values
	 * @return
	 */
	public Object findFirst(String hql, Object... values);

	
	
	/**
	 * 批量删除
	 * @param entities
	 */
	public void deleteAll(Collection<?> entities);

	/**
	 * 条件查询指定字段的和
	 * 
	 * @param criteria
	 * @param propertyName
	 * @return
	 */
	public Object getSumByProperty(DetachedCriteria criteria, String propertyName);

	/**
	 * Sql统计总数
	 * 
	 * @param sql
	 * @param o
	 * @return
	 */
	public Object countOfSql(String sql, Object... o);

	/**
	 * HQL统计总数
	 * 
	 * @param hql
	 * @param o
	 * @return
	 */
	public int countOfHql(String hql, Object... o);


	/**
	 * 返回List查询
	 * @param hql
	 * @param o
	 * @return
	 */
	public List<?> queryList(final String hql, final Object... o);

	/**
	 * 分页查询
	 * 
	 * @param hql
	 * @param first
	 * @param limit
	 * @param o
	 * @return
	 */
	public List<?> queryListPage(final String hql, int first, int limit, final Object ...o);

	/**
	 *
	 * @param sql
	 * @return
	 */
	public List<Object> getSqlList(String sql);

	/**
	 * 返回List的HQL查询
	 * 
	 * @param hql
	 * @return
	 */
	public List<?> findList(String hql);

	/**
	 * 
	 * @param hql
	 * @param map
	 */
	public int executeUpdate(String hql, Map<String, Object> map);

	public List<?> getHqlList(final String sql, int first, int end, final Object... o);

	public List<?> getListByNativeSql(String sql, Object... o);

	/**
	 * 根据hql,返回Query
	 * 
	 * @author Monster
	 * @param hql
	 * @return
	 */
	public Query getQuery(final String hql);

	/**
	 * 根据sql,返回Query
	 * 
	 * @author Monster
	 * @param hql
	 * @return
	 */
	public Query getSqlQuery(final String sql);

	/**
	 * 查询命名参数hql语句结果
	 *
	 * @author wangzheng
	 * @param hql
	 * @param params
	 * @return
	 */
	List<T> getNamedHql(String hql, Map<String, Object> params);
	
	
	
	
	/**
	 * 
	 * @author yang
	 * @return
	 */
	@Deprecated
	public List<? extends Object> getList(String[] paramNames, String[] paramValues);
	
	@Deprecated
	public List<? extends Object> getRows(String[] paramNames, String[] paramValues);
	
	/**
	 * 根据ID,返回T,没有找到,返回null
	 * @param pk
	 * @return
	 */
	public T getInfo(PK pk);
	

	/**
	 * 获取T,没有找到,返回null
	 * @param clazz
	 * @param pk
	 * @return
	 */
	public T getInfo(Class<T> clazz, PK pk);
	
	/**
	 * 获取T,没有找到,返回null
	 * @param clazz
	 * @param pk
	 * @return
	 */
	public Base getInfo(PK pk, Class<T> clazz);
	
	
	/**
	 * 根据ID,返回T,返回代理对象
	 * @param pk
	 * @return
	 */
	public T loadInfo(PK pk);
	
	/**
	 * 保存后,返回ID
	 * @param t
	 * @return
	 */
	public Serializable saveInfo(T t);
	
	/**
	 * 保存
	 * @param t
	 * @return
	 */
	public Serializable save(Object object);
	
	/**
	 * 比较数据后,保存或更新,返回T,
	 * @param t
	 * @return
	 */
	public T mergeInfo(T t);
	
	/**
	 * 保存
	 * @param t
	 */
	public void updateInfo(T t);
	

	/**
	 * 更新
	 * @param b
	 */
	public void updateInfo(Base b);
	
	/**
	 * 移除
	 * @param pk
	 */
	public void removeInfo(PK pk);
	
	/**
	 * 获取总记录数
	 * @param dc
	 * @return
	 */
	public int getTotalRecord(DetachedCriteria dc);
	
	/**
	 * 分页查询数据
	 * @param criteria
	 * @param beginNum
	 * @param endNum
	 * @return
	 */
	public List<T> findByCriteria(final DetachedCriteria dc, final Integer firstResult, final Integer maxResults);
	
	/**
	 * 获取class
	 * @param criteria
	 * @return
	 */
	public Class<T> getClazz();
	
	/**
	 * 设置class
	 * @param clazz
	 */
	public void setClazz(Class<T> clazz);
	

	/**
	 * 获取分页
	 * @param page
	 * @return
	 */
	public List<T> findByPageGrid(PageGrid page);
	
	/**
	 * 条件查询对象
	 * @param parameters
	 * @return
	 */
	public T getInfo(BaseParameters parameters);
	
	/**
	 * 条件查询对象
	 * @param dc
	 * @return
	 */
	public T getInfo(DetachedCriteria dc);
	
	/**
	 * 根据参数, 查询对象集合
	 * @param parameters
	 * @return
	 */
	public List<T> getInfoList(BaseParameters parameters);
	
	/**
	 * 设置参数
	 * 
	 * @author Monster
	 * @param query
	 * @param o
	 */
	public Query setQueryParams(Query query, Object[] o);
	
	/**
	 * 设置参数,Map
	 * 
	 * @author Monster
	 * @param query
	 * @param map
	 */
	public Query setQueryParams(Query query, BaseParameters parameters);

}
jquery 合并列里面的相同行
/***
 * // 封装的一个JQuery小插件,定义rowspan方法合并相同列
 * 如要合并第一列: $("#id").rowspan(0);
 */
jQuery.fn.rowspan = function(colIdx) { 
	return this.each(function() {
		var that;
		$('tr', this).each(
			function(row) {
				$('td:eq(' + colIdx + ')', this).filter(':visible').each(
					function(col) {
						if (that != null
								&& $(this).html() == $(that).html()) {
							rowspan = $(that).attr("rowSpan");
							if (rowspan == undefined) {
								$(that).attr("rowSpan", 1);
								rowspan = $(that).attr("rowSpan");
							}
							rowspan = Number(rowspan) + 1;
							$(that).attr("rowSpan", rowspan);
							$(this).hide();					//隐藏该单元格				
							$(this).find("input").remove();	//删除掉里面的input, 避免提交到后台
							//$(this).remove();
						} else {
							that = this;
						}
				});
			});
	});
} 
springMvc.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:util="http://www.springframework.org/schema/util"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
	xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:aop="http://www.springframework.org/schema/aop"
	xmlns:tx="http://www.springframework.org/schema/tx"
	xsi:schemaLocation="
		http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
        http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
        http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
        http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.2.xsd"
	default-autowire="byName">

	<!-- 扫描注解Controller -->
	<context:component-scan base-package="com.cnpay.smf,com.cnpay.common,com.cnpay.demo,com.cnpay.base">
		<context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
		<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Service"/>
	</context:component-scan>
	
	<!-- 拦截切入点 -->
<!-- 	<aop:config>
		<aop:pointcut id="paremeterValidater" expression="execution(public * com.cnpay.mdf.controller.*.*(..))"/>
		<aop:advisor pointcut-ref="paremeterValidater" advice-ref="controllerInterceptor"/>
	</aop:config> -->
	
	
	<!-- springmvc 视图解析器 -->
	<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
		<property name="prefix" value="/WEB-INF/view/" />
		<property name="suffix" value=".jsp" />
		<property name="viewClass" value="org.springframework.web.servlet.view.JstlView" />
	</bean>
	
	<!-- modify by wangzheng START 支持默认json时间转换格式yyyy-MM-dd HH:mm:ss -->
	<!-- springmvc注解映射支持, fastxmlJson框架支持  + hibernate validate4验证 -->
<!-- 	<mvc:annotation-driven validator="validator"> -->
<!-- 		<mvc:message-converters register-defaults="true"> -->
<!-- 			<bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter"> -->
<!-- 				<property name="supportedMediaTypes" value="application/json;charset=UTF-8" /> -->
<!-- 			</bean> -->
<!-- 		</mvc:message-converters> -->
<!-- 	</mvc:annotation-driven> -->
	
	   <!-- Enables the Spring MVC @Controller programming model --> 
   <mvc:annotation-driven validator="validator" enableMatrixVariables="true">
	  <!-- 消息转换器,配置转换成json格式的转换器 --> 
      <mvc:message-converters register-defaults="true"> 
         <!-- 避免IE执行AJAX时,返回JSON出现下载文件 --> 
         <bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter"> 
            <property name="supportedMediaTypes"> 
               <list> 
                  <value>application/json;charset=UTF-8</value> 
                  <value>text/html;charset=UTF-8</value> 
               </list> 
            </property> 
            <property name="objectMapper"> 
               <bean class="com.fasterxml.jackson.databind.ObjectMapper"> 
                  <property name="dateFormat"> 
                     <bean class="java.text.SimpleDateFormat"> 
                        <constructor-arg type="java.lang.String" value="yyyy-MM-dd HH:mm:ss" /> 
                     </bean> 
                  </property> 
               </bean> 
            </property> 
         </bean> 
         <bean class="org.springframework.http.converter.StringHttpMessageConverter">    
             <constructor-arg value="UTF-8"/>    
         </bean>  
      </mvc:message-converters> 
	  <!-- 参数解析器 -->
      <mvc:argument-resolvers>
		<bean class="com.cnpay.common.web.resolver.CascadeParamMethodArgumentResolver" />
		<bean class="com.cnpay.common.web.resolver.CascadedParamMethodArgumentResolver" />
		<bean class="com.cnpay.common.web.resolver.MyHandlerMethodArgumentResolver" />
		<bean class="com.cnpay.common.web.resolver.MyServletModelAttributeMethodProcessor" />
      </mvc:argument-resolvers>  
   </mvc:annotation-driven>
   <!--  modify by wangzheng END -->
	
	
	<!-- springmvc验证,使用hibernate validation -->
	<bean id="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean">
		<property name="providerClass" value="org.hibernate.validator.HibernateValidator" />
		<property name="validationMessageSource" ref="messageSource" />
	</bean>
	
	<!-- 启用基于注解的处理器映射,添加拦截器,类级别的处理器映射 -->
	<!-- <bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping">
		<property name="order" value="1" />
	</bean> -->

	<!-- REST, 配置返回json, xml -->
	<bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
		<property name="order" value="1" />
		<property name="contentNegotiationManager">
			<bean class="org.springframework.web.accept.ContentNegotiationManager">
				<constructor-arg>
					<bean
						class="org.springframework.web.accept.PathExtensionContentNegotiationStrategy">
						<constructor-arg>
							<map>
								<entry key="json" value="application/json" />
								<entry key="xml" value="application/xhtml-xml" />
								<entry key="swf" value="application/x-shockwave-flash" />
							</map>
						</constructor-arg>
					</bean>
				</constructor-arg>
			</bean>
		</property>
	</bean>


	<!-- i18n资源文件绑定 -->
	<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
		<property name="basename" value="i18n/message" />
		<property name="useCodeAsDefaultMessage" value="true" />
	</bean>

	<!-- 配置拦截器 -->
	<!-- <bean id="interceptor" class="com.cnpay.mdf.system.resource.controller.LogonInterceptor" /> -->

	<!-- 配置拦截器 -->
	<mvc:interceptors>
		<mvc:interceptor>
			<mvc:mapping path="/**" />
			<bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor" />
		</mvc:interceptor>
		<mvc:interceptor>
			<mvc:mapping path="/**" />
			<bean class="com.cnpay.smf.system.common.interceptor.LogonInterceptor">
				<property name="allowUrls">
					<list>
						<!--忽略拦截路径 -->
						<value>/systAdminUser/adminLogon</value>
						<value>/systAdminUser/getImage</value>
						<value>/bin/</value>
						<value>/css/</value>
						<value>/file/</value>
						<value>/img/</value>
						<value>/js/</value>
						<value>/package/</value>
						<value>/template/</value>
						<value>/test/</value>
						<value>/view/</value>
						<value>/page/</value>
					</list>
				</property>
			</bean>
		</mvc:interceptor>
	</mvc:interceptors>

	<!-- 配置异常跳转 -->
	<bean id="exceptionResolver" class="com.cnpay.common.util.exception.SystemExceptionHandler">
		<property name="exceptionMappings">
			<props>
				<prop key="com.cnpay.common.util.exception.BaseException">/../../view/exception</prop>
				<prop key="java.lang.Exception">/../../view/error</prop>
			</props>
		</property>
	</bean>
	
	<!-- springmvc支持文件上传 -->  
    <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">  
            <!-- set the max upload size100MB(100 * 1024 * 1024 = 104857600) -->  
            <property name="maxUploadSize" value="104857600" />  
            <property name="maxInMemorySize" value="4096" />
            <property name="defaultEncoding" value="UTF-8" />
     </bean>  
	
    
	<!-- 配置静态资源访问 -->
	<mvc:resources mapping="/page/**" location="/page/"/> 
	<mvc:resources mapping="/css/**" location="/css/"/>
	<mvc:resources mapping="/js/**" location="/js/"/>
	<mvc:resources mapping="/img/**" location="/img/"/>
	<mvc:resources mapping="/bin/**" location="/bin/"/>
	<mvc:resources mapping="/test/**" location="/test/"/>
    <mvc:resources mapping="/template/**" location="/template/"/>
    <mvc:resources mapping="/data/**" location="/data/"/>
    <mvc:resources mapping="/upload/**" location="/upload/"/>
	<mvc:resources mapping="/file/**" location="/file/"/>
	
	<!-- <bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">  
     	<property name="urlMap">  
     		<map>  
              <entry key="/**" value="resourceHandler" />  
        	</map>  
     	</property>  
    	<property name="order" value="100000" />         
	</bean> -->
	
	<bean id="resourceHandler" class="org.springframework.web.servlet.resource.ResourceHttpRequestHandler">  
      <property name="locations" value="/" />  
      <property name="supportedMethods">  
         <list>  
            <value>GET</value>  
            <value>HEAD</value>  
            <value>POST</value>  
         </list>  
     </property>
	</bean>   
</beans>
spring mvc applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:p="http://www.springframework.org/schema/p" xmlns:util="http://www.springframework.org/schema/util"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
	xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop"
	xmlns:jee="http://www.springframework.org/schema/jee"
	xsi:schemaLocation="http://www.springframework.org/schema/beans
		http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
		http://www.springframework.org/schema/context
		http://www.springframework.org/schema/context/spring-context-3.2.xsd
		http://www.springframework.org/schema/aop
		http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
		http://www.springframework.org/schema/tx
		http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
		http://www.springframework.org/schema/jee 
		http://www.springframework.org/schema/jee/spring-jee-3.2.xsd" default-autowire="byName" default-lazy-init="true">
	
	<!-- 开启注解支持 -->
	<context:annotation-config />
	
	<!-- 扫描注解类,并排除过滤 Controller-->
	<context:component-scan base-package="com.cnpay.smf,com.cnpay.demo,com.cnpay.common,com.cnpay.base">
		<context:include-filter type="aspectj" expression="com.cnpay.common.util.exception.ExceptionTraceAspect"/>
		<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller" />
	</context:component-scan>

	<!-- 该 BeanPostProcessor 将自动对标注 @Autowired 的 Bean 进行注入 -->
	<bean class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor" />
	<bean class="org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator" />

	<!-- JNDI获取DataSource -->
	<jee:jndi-lookup id="dataSource" jndi-name="java:comp/env/FINSER" />

	<!-- 会话工厂 -->
	<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
		<property name="dataSource" ref="dataSource" />
		<property name="packagesToScan" value="com.cnpay.**.entity*" />
		<property name="mappingResources">
			<list>
			    <value>hbm/snaker.ccorder.hbm.xml</value>  
			    <value>hbm/snaker.order.hbm.xml</value>  
			    <value>hbm/snaker.process.hbm.xml</value>  
			    <value>hbm/snaker.surrogate.hbm.xml</value>  
			    <value>hbm/snaker.task.hbm.xml</value>  
			    <value>hbm/snaker.taskactor.hbm.xml</value>  
			    <value>hbm/snaker.workitem.hbm.xml</value>  
			</list>
		</property>
		<property name="hibernateProperties">
			<props>
				<prop key="hibernate.max_fetch_depth">3</prop>
				<!-- <prop key="hibernate.hbm2ddl.auto">update</prop> -->
				<prop key="hibernate.show_sql">true</prop>
				<prop key="hibernate.dialect">org.hibernate.dialect.OracleDialect</prop>
			</props>
		</property>
	</bean>
	
	<!-- 会话工厂 ,注入到事物管理器 -->
	<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
		<property name="sessionFactory" ref="sessionFactory" />
	</bean>
    
    <!-- 如果使用HibernateTempate -->
    <bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
        <property name="sessionFactory" ref="sessionFactory" />
     </bean>
	
	<!-- Spring JTA 支持 @Transactional -->
	<tx:annotation-driven transaction-manager="transactionManager"/>
	
	<!-- 支持 @AspectJ -->
	<aop:aspectj-autoproxy /> <!-- 默认代理接口类 -->
	
	<!-- 配置 aop事物通知-->
	<tx:advice id="txAdvice" transaction-manager="transactionManager">
		<tx:attributes>
			<tx:method name="find*" propagation="REQUIRED" rollback-for="java.lang.Exception"/>
			<tx:method name="get*" propagation="REQUIRED" rollback-for="java.lang.Exception"/>
			<tx:method name="add*" propagation="REQUIRED" rollback-for="java.lang.Exception"/>
			<tx:method name="insert*" propagation="REQUIRED" rollback-for="java.lang.Exception"/>
			<tx:method name="delete*" propagation="REQUIRED" rollback-for="java.lang.Exception"/>
			<tx:method name="remove*" propagation="REQUIRED" rollback-for="java.lang.Exception"/>
			<tx:method name="modi*" propagation="REQUIRED" rollback-for="java.lang.Exception"/>
			<tx:method name="alter*" propagation="REQUIRED" rollback-for="java.lang.Exception"/>
			<tx:method name="save*" propagation="REQUIRED" rollback-for="java.lang.Exception"/>
			<tx:method name="update*" propagation="REQUIRED" rollback-for="java.lang.Exception"/>
			<tx:method name="merge*" propagation="REQUIRED" rollback-for="java.lang.Exception"/>
			<tx:method name="edit*" propagation="REQUIRED" rollback-for="java.lang.Exception"/>
			<tx:method name="start*" propagation="REQUIRED" rollback-for="java.lang.Exception"/>
			<tx:method name="approve" propagation="REQUIRED" rollback-for="java.lang.Exception"/>
			
			<!-- 工作流中多出的配置 -->
    		<tx:method name="assign*" propagation="REQUIRED" />
    		<tx:method name="execute*" propagation="REQUIRED"/>
		    <tx:method name="create*" propagation="REQUIRED" />
		    <tx:method name="complete*" propagation="REQUIRED" />
		    <tx:method name="finish*" propagation="REQUIRED" />
		    <tx:method name="terminate*" propagation="REQUIRED" />
		    <tx:method name="take*" propagation="REQUIRED" />
		    <tx:method name="deploy*" propagation="REQUIRED" />
		    <tx:method name="redeploy*" propagation="REQUIRED" />
		    <tx:method name="undeploy*" propagation="REQUIRED" />
		    <tx:method name="withdrawTask*" propagation="REQUIRED" />
		    <tx:method name="native*" propagation="REQUIRED" />
		    <tx:method name="query*" propagation="REQUIRED" read-only="true" />
		    <tx:method name="search*" propagation="REQUIRED" read-only="true" />
		    <tx:method name="is*" propagation="REQUIRED" read-only="true" />
		    
			<tx:method name="*" propagation="REQUIRED"/>
			<!-- Write operations are not allowed in read-only mode (FlushMode.MANUAL) -->
		</tx:attributes>
	</tx:advice>
	
	<aop:config>
		<!-- 声明事物切入点 -->
		<aop:pointcut id="servicePointcut" expression="execution(* com.cnpay..*.*(..)) or execution(* org.snaker.engine..*.*(..))" />
		<!-- 切面 -->
		<aop:advisor pointcut-ref="servicePointcut" advice-ref="txAdvice" />
		<!--方法权限控制 -->
		<aop:aspect ref="methodFilter">
			<aop:around pointcut-ref="servicePointcut" method="doMethodBefore" />
		</aop:aspect>
	</aop:config>
	
	
	<bean id="dbAccess" class="org.snaker.engine.access.hibernate.Hibernate3Access">
		<property name="sessionFactory" ref="sessionFactory"/>
    </bean>
	<!-- 流程引擎配置 -->
	<bean id="snakerEngine" class="org.snaker.engine.spring.SpringSnakerEngine">
	    <property name="processService" ref="processService"/>
	    <property name="orderService" ref="orderService"/>
	    <property name="taskService" ref="taskService"/>
	    <property name="queryService" ref="queryService"/>
	    <property name="managerService" ref="managerService"/>
	</bean>
	<bean id="processService" class="org.snaker.engine.core.ProcessService">
	    <property name="access" ref="dbAccess"/>
	    <property name="cacheManager" ref="cacheManager"/>
	</bean>
	<bean id="orderService" class="org.snaker.engine.core.OrderService">
	    <property name="access" ref="dbAccess"/>
	</bean>
	<bean id="taskService" class="org.snaker.engine.core.TaskService">
	    <property name="access" ref="dbAccess"/>
	</bean>
	<bean id="managerService" class="org.snaker.engine.core.ManagerService">
	    <property name="access" ref="dbAccess"/>
	</bean>
	<bean id="queryService" class="org.snaker.engine.core.QueryService">
	    <property name="access" ref="dbAccess"/>
	</bean>
    <bean id="cacheManager" class="org.snaker.engine.cache.memory.MemoryCacheManager"/>
    <bean class="org.snaker.engine.impl.LogInterceptor"/>
    <bean class="org.snaker.engine.spring.SpelExpression"/>
    <bean class="org.snaker.engine.impl.SurrogateInterceptor"/>
    <!-- <bean class="com.cnpay.common.workflow.WfDeploymentHelper">
    	<property name="snakerEngine" ref="snakerEngine"/>
    </bean> -->
	
</beans>
Global site tag (gtag.js) - Google Analytics