In our DB we have multiple entities with Date fields. Oracle sees every date as the same, with a date and a time part. JPA entities however distinguish via the annotaton @Temporal. When we want to omit the time part we annotate Date fields with @Temporal(TemporalType.DATE) and Oracle saves 00:00:00, if not, we just leave it without annotation.
Example:
@Entity
public class MyEntity implements Serializable {
private static final long serialVersionUID = 1L;
@Id
private long myentityId;
@Temporal(TemporalType.DATE)
private Date importantDate; //01.01.2015 00:00:00
private Date creationDate; //01.01.2015 10:35:51
...
}
...
MyEntity me = new MyEntity();
me.setImportantDate(new Date());
me.setCreationDate(new Date());
...
We upgraded from Oracle 11 to Oracle 12 and now the time part of importantDate is no longer omitted!
I tested this extensively on both databases with exactly the same program. This actually breaks our application.
What can I do to restore the previous behaviour?
UPDATE 1: I narrowed the problem down: driver ojdbc6 12.1.0.1.0 has the problem, ojdbc6 11.2.0.3.0 works as intended. (both using an Oracle 12 DB)
Is this a continuation of the timestamp problem fixed in 11.1? (http://www.oracle.com/technetwork/database/enterprise-edition/jdbc-faq-090281.html#08_01)
UPDATE 2: Since Hibernate does not seem to be the problem, I wrote an example with pure JDBC:
OracleDataSource ods = new OracleDataSource();
...
Connection conn = ods.getConnection();
PreparedStatement ps = conn.prepareStatement("UPDATE MyEntity SET importantDate = ? WHERE myentityId = 4385");
ps.setDate(1, new java.sql.Date(new java.util.Date().getTime()));
ps.execute();
...
This snippet behaves different when switching between ojdbc6 11.1 and ojdbc6 12.1.
Oracle12cDialect
?