The Date type stored in the database is only year, month, and day, and there is no hour, minute, and second reason and Solution

Source: Internet
Author: User
Problem: The Date type stored in the database is only year, month, and day. I have tried several methods without hour, minute, and second. The result is year, month, and day. It is clear that there can be hour, minute, and second in some places... later I thought that I did not pay attention to any time-related point. I use the object generated by the hibernate plug-in of jboss and the hbm. xml configuration file. Although I have configured the primary key

Problem: The Date type stored in the database is only year, month, and day. I have tried several methods without hour, minute, and second. The result is year, month, and day. It is clear that there can be hour, minute, and second in some places... later I thought that I did not pay attention to any time-related point. I use the object generated by the hibernate plug-in of jboss and the hbm. xml configuration file. Although I have configured the primary key

Problem:The Date type stored in the database is year, month, day, and no hour, minute, and second.


I have tried several methods, and the result is year, month, and day. It is clear that there are hours, minutes, And seconds in some places...


Later I thought that I did not pay attention to any time-related point. I use the hibernate plug-in of jboss to generate objects and hbm. in the xml configuration file, although I have configured the primary key type, I use the default values for other fields and check hbm. xml file.


Cause:Hibernate uses basic types when generating this configuration file.


The String type is not written in java. lang. String, but in string.

The Date type is not written in java. util. Date, but in date.

This applies to other types.

(This date and string look strange. I don't know where it comes from... Maybe it's hibernate ?)

Solution:Instantly discover the problem, change it to the correct type, and try again.


In the past, when myeclipse was used, the configuration files of the hibernate plug-in were not manually configured and are directly generated. Using the Eclipse + plug-in, I did not expect to manually configure so much content.



Attach a configuration file:

 
 
  
  
   
   
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
 

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.