This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
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
Register / Login


JavaRanch » Java Forums » Databases » Object Relational Mapping
Reply 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: 56554
    
  14

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


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About 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: 56554
    
  14

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
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Inserting Java Date in MySQL as Datetime
 
Similar Threads
comparing two dates
how to compare sql date
Date in Hibernate
Hibernate: MySql DATETIME to java.util.Date
count by current timestamp