1.java.sql.date and Java.util.Date
Java.sql.Date is inherited from Java.util.Date and assumes that dates1 (java.sql.Date) is assigned to Dates2 (java.util.Date)
Dates2=new java.sql.Date (Dates1.gettime ()) can be performed by the following conversions;
2. The difference between the methods in Preparestament Settimestamp () and setdate () and getdate (), Gettimestamp () in resultset:
Gettimestamp (), Settimestamp () will get/set "date + Time" in the database, or it can be said to be a timestamp
GetDate (), setDate () ignores time, only gets/sets the "date" in which
To encounter a problem like this
When hibernate is applied, the Qurey object Qurey
Problem:
Query Query =ses.createquery (HQL);
Query. setDate ("EndTime", Newdate ());
At this time, the new Date () is truncated for seconds.
Workaround:
Java code
Query Query =ses.createquery (HQL);
Query. Settimestamp ("EndTime", Newdate ());
Summary: 1. If the datetime type is displayed in the database, use query.
Settimestamp("EndTime", newdate can be solved ()); This problem can be set time to hour and seconds
Statement in HQL in hibhibernate the WHERE statement query list appears empty