What if we use
@Column(name=\"birth_date\", nullable=false, length=19)
public Date getBirthDate() {
return this.birthDate;
}
instead of
Only piece of documentation I managed to find:
In plain Java APIs, the temporal precision of time is not defined. When dealing with temporal data you might want to describe the expected precision in database. Temporal data can have DATE, TIME, or TIMESTAMP precision (ie the actual date, only the time, or both). Use the @Temporal annotation to fine tune that.
From 2.2.2.1. Declaring basic property mappings.
This might indicate that the actual date representation in the database is not defined and to be sure it is better to specify it directly.
I realize this question was already answered but we struggled with this today so I wanted to give some more insight for future people who stumble across this.
Using Oracle 11g with the version 11 drivers if you do not use the temporal annotation then every date, time, and timestamp data type from Oracle will map to a timestamp in your code at runtime. Functionally this is fine, however this caused us severe performance issues. This was because we had a DATE type as part of a compound primary key. This column was the leading column of the index as well as the column we used for partitioning. When the driver would try to persist records with this column in the where clause Oracle would perform a type conversion of the data in the DB from DATE to TIMESTAMP. This made the index useless and performance was horrible.
Long story longer, add this annotation always lest ye be prepared to pay the price.