File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes Inserting Java Date in MySQL as Datetime Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Inserting Java Date in MySQL as Datetime" Watch "Inserting Java Date in MySQL as Datetime" New topic
Author

Inserting Java Date in MySQL as Datetime

Nicolás Muñoz
Greenhorn

Joined: Nov 11, 2009
Posts: 17
Hi, I am trying to insert a date from Java to a MySQL database (DATETIME) using Hibernate. Hibernate maps a Datetime as a java.util.Date but this class has many methods which have been deprecated. I don't know what I'm supposed to do. Thanks for any help
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60048
    
  65

What's the problem? Just don't use the deprecated methods.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Nicolás Muñoz
Greenhorn

Joined: Nov 11, 2009
Posts: 17
I know I must not use them. I guess my real question is: what steps should I follow to correctly insert a Datetime in MySQL using Hibernate?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60048
    
  65

You'll need to be more specific as to what your problem is. The whole point of Hibernate is that you shouldn't need to worry about the details. Is your question that you are unsure how to go about mapping Date fields?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Just because some methods are deprecated doesn't mean the *class* is deprecated.
ahmad seddighi
Greenhorn

Joined: Jun 22, 2004
Posts: 16
take a look at http://www.xmission.com/~goodhill/dates/datedeprecation.htm
------------------------------------------------------------------------------------------------------------


Spring Persistence with Hibernate
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Inserting Java Date in MySQL as Datetime
 
Similar Threads
count by current timestamp
Date in Hibernate
how to compare sql date
comparing two dates
Hibernate: MySql DATETIME to java.util.Date