This seems like such a bonehead question, but I\'ve been chasing my tail around a tree all day. I have a Struts 2 + Spring3/JPA/Hibernate application that inserts a large set in
For this kind of problems, it usually helps to provide the version of the JDBC driver and the dialect you're using.
Anyway, my understanding is that you actually want the following mapping (for DATE and TIME):
@Column(name = "READING_DATE")
@Temporal(TemporalType.TIMESTAMP)
private Date readingDate;
And the problem you're facing is somehow related to the madness introduced by Oracle with version 9.2, see What is going on with DATE and TIMESTAMP? (in short, they introduced a TIMESTAMP
column and changed the mapping of the DATE
SQL type, read the FAQ). There are several options to solve it (I am of course assuming you are using a TemporalType.TIMESTAMP
mapping):
Either use a TIMESTAMP
column type (I don't mean TemporalType.TIMESTAMP
here, I really mean the column type on the DB side). But if you don't need nanosecond precision, this is not the best choice.
Or set the oracle.jdbc.V8Compatible=true
compatibility mode, either as system property or as a connection property:
true
Yes, you can set arbitrary connection properties like this. From the Hibernate documentation:
3.3. JDBC connections
...
Arbitrary connection properties can be given by prepending "hibernate.connection" to the connection property name. For example, you can specify a
charSet
connection property usinghibernate.connection.charSet
.
Or use Oracle JDBC 11.1 driver (they "fixed" the problem by reverting the change). This is IMO the ideal solution (the V8Compatible
stuff is deprecated).