File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Object Relational Mapping and the fly likes mapping column of Date type Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "mapping column of Date type" Watch "mapping column of Date type" New topic

mapping column of Date type

ben oliver
Ranch Hand

Joined: Mar 28, 2006
Posts: 375
In oracle database tbale "EVENT" I have some columns of "DATE" type. In the hibernate mapping file I specify as

<propery name="event_date" column="EVENT_COLUMN"/>

In the POJO "Event" class I have

private java.util.Date event_date;

Howevere I found it didn't work properly. Do I have to a


in the hibernate mapping file ? like

<propery name="event_date" type="date" column="EVENT_COLUMN"/>

Vassili Vladimir
Ranch Hand

Joined: Mar 08, 2007
Posts: 1585

Here's an example:


Vassili ...
SCJP 5.0, SCWCD 1.4, SCJA 1.0
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968

You know, annotations make things so much easier.

public java.util.Date getLastAccessTime() {
return lastAccessTime;

public java.util.Calendar getRegistrationDate() {
return registrationDate;

Performing Date and Time Column Mappings with Hibernate and JPA Annotations


It's noteworthy to point out how the registrationDate column, which is annotated to be TemporalType.DATE, simply gets a year-month-day value, whereas the lastAccessTime column is populated with a full timestamp, including both the day and the time (TemporalType.TIME is the third option which would have simply saved the time, and not the calendar day). By the way, TemporalType.TIMESTAMP is the default if it isn't otherwise specified in your code.

-Cameron McKenzie
I agree. Here's the link:
subject: mapping column of Date type
jQuery in Action, 3rd edition