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);
        }

  • 相关阅读:
    转:桩模块 stub 和驱动模块 driver
    音频中PCM的概念
    pthread_exit
    为什么匿名内部类参数必须为final类型
    原创:同步与异步、阻塞与非阻塞
    (转)C语言中长度为0的数组
    编码问题
    查看Android程序使用内存
    C++中class与struct的区别(struct的类型名同时可以作为变量名)
    asn1c
  • 原文地址:https://www.cnblogs.com/attilax/p/5963988.html
Copyright © 2011-2022 走看看