hql组合条件查sum的方法

@Query("select sum(r.amount) from RechargeOrder r where 1=1  " +
            "AND (case when (:status is null) then true when(:status=r.status) then true else false end)=true " +
            "AND (case when (:walletType is null) then true when(:walletType=r.walletType) then true else false end)=true " +
            "AND (case when (:payType is null) then true when(:payType=r.payType) then true else false end)=true " +
            "AND (case when (:userId is null) then true when(:payType=r.userId) then true else false end)=true " +
            "AND (case when (:rechargeType is null) then true when(:rechargeType=r.rechargeType) then true else false end)=true " +
            "AND (case when (:successTimeBegin is null) then true when(:successTimeBegin<=r.successTime) then true else false end)=true " + "AND (case when (:successTimeEnd is null) then true when(:successTimeEnd>=r.successTime) then true else false end)=true " +

            "")
    Integer sumAmount(
            @Param("status")  Integer status
            ,@Param("walletType")  Integer walletType
            ,@Param("payType")  Integer payType
            ,@Param("userId")  Integer userId
            ,@Param("rechargeType")  Integer rechargeType
            ,@Param("successTimeBegin")  Date successTimeBegin
            ,@Param("successTimeEnd")  Date successTimeEnd
    );

mysql存储引擎总结

主要就两个 myisam 和 innodb

myisam这里有详细的例子:
http://hfhwan.iteye.com/blog/375611
总结:
没有事物,表锁,读写互斥的锁,锁只能锁当前session,不影响其他用户,适合读多于写的数据。
存在一个系统变量 concurrent_insert 允许并发插入的设置

innodb的例子:
http://blog.chinaunix.net/uid-24111901-id-2627857.html
总结:
有事务,可以行锁,行锁前提是有索引否则又变成了表锁,而且锁上别的session就影响了。适合写入修改多的情况。
锁是对索引加的,两个查询相同索引的内容也会有影响。。。
涉及到钱的用这个