Hibernate use Date,
Oracle can be set to date, date can be accurate to seconds, and when Java adds an accurate to a second date to the database, you can directly
Set (new Date ()), which is displayed in the database in 2015/10/17 16:15:13, directly with Session.get (), to get
The date is 2015-10-17 16:15:13.0
When the Oracle database is set to timestamp (6), the direct set (new Date ()) database displays: 1 July-October-15
04.32.11.566000 afternoon. Java Direct session.get () out When: 2015-10-17 16:32:11.566, in the data
The precision timestamp (0) of timestamp (6) can be set in the library. Of course, the extracted data can be formatted.
The date type in the Java entity class is the same as the date type in the Hbm.xml configuration file, which is java.util.Date
The date in the <property name= "Stubirth" type= "date" column= "Stu_birth" is/> by default.
Java.util.Date corresponds to timestamp (6) in Oracle,
Java.sql.Date corresponds to Date in Oracle.
Inserts new Date () when the type is different (for example, the Java entity class uses java.util.date,hbm.xml with Java.sql.Date)
, the date will only be inserted in 2015-10-17. Enquiries will only be found on the date 2015-10-17. Therefore, it must be noted here, we must ensure that the Java real
Body class and Hbm.xml date type (), HBM type can not write, according to the Java class automatic conversion type;
If you want to change the date format in the database, you must use the SQL To_date () to turn it on at the time of insertion.
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.