zoukankan      html  css  js  c++  java
  • paip.取当天记录的方法sql跟hql hibernate



    paip.取当天记录的方法sql跟hql hibernate

    #------两个方法...函数法和日期计算法..
    函数法: DATEDIFF(d,createTime,GETDATE())=0   //d指定为day
    hb也有一样的函数..
    日期 计算法: where  createTime>='2014-5-4 00:00:01' and createTime<='2014-5-4 23:59:59'
    where  createTime='2014-5-4 00:00:00'

    应该优先使用日期 计算法,,因为这个方法能使用索引了...不个日期时间转换为long数字...

    作者 老哇的爪子 Attilax 艾龙,  EMAIL:1466519819@qq.com
    转载请注明来源: http://blog.csdn.net/attilax

    #-----如下
        public AwardWeixin todayJoinRecode(String uid, String actid) {
            // 下午12:53:37 2014-4-30
            Session session = getSession();
            String hql = "from AwardWeixin where activityId = ? and openid=? and createtime=?";
            List<AwardWeixin> awardList = null;
            Query q = session.createQuery(hql);
            q.setParameter(0, actid);
            q.setParameter(1, uid);
            q.setParameter(2, DateUtil.today_notime());
            awardList = q.list();

            // if (awardList.size() == 0) // new user add 3tsi
            // {}
            // System.out.println(awardList.size());
            return awardList.get(0);
        }

  • 相关阅读:
    PHPStrom 转 VSCode 折腾记录
    vscode php 代码提示 自动完成
    Elasticsearch中文分词加拼音
    AutoMapper用法
    删除所有退出状态的容器
    Linux 安装Docker
    千里眼的修练方法--末法时代即将结束
    Visual NMP
    c#通过反射获取类上的自定义特性
    微信小程序学习笔记
  • 原文地址:https://www.cnblogs.com/attilax/p/5963988.html
Copyright © 2011-2022 走看看