Paip. Methods for taking the day's records SQL and HQL hibernate

Source: Internet
Author: User



Paip. Methods for taking the day's records SQL and HQL hibernate

#------of two ways ... function method and Date calculation method:
Function method: DATEDIFF (D,createtime,getdate ()) =0//d specified as Day
HB also has the same function:
Date calculation method: Where createtime>= ' 2014-5-4 00:00:01 ' and createtime<= ' 2014-5-4 23:59:59 '
where createtime= ' 2014-5-4 00:00:00 '

The date calculation should be used preferentially, because this method can use the index ... Do not convert a datetime to a long number ...

Author of Old Wow's Paw attilax Ayron, email:[email protected]
Reprint please indicate source: Http://blog.csdn.net/attilax

#-----as follows
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);
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.