Hi,
I support an application using Hibernate to access a DB2 database. We are migrating the database to Oracle 12c. We are running into issues with the differing string representations for timestamps used by DB2 and Oracle.
Our DB2 timestamp data is stored as strings with a column format of CHAR(26). The string format for our existing data is YYYY-MM-DD HH24:MI:SS.FF3. The Oracle default is DD-MON-RR HH.MI.SSXFF AM, so on reads Oracle can't parse the existing data, and on insert it fails because it needs room for 31 characters.
Our value objects (our pojo's) hold the timestamps in java.util.Date. The string conversions are being handled implicitly by Hibernate. Here's an example of one of our hibernate mapping files:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.foo.bar.LastModified" table="LastModified" >
<id name="resourceId" type="string" >
<generator class="assigned"/>
</id>
<property name="timeLastMod" type="string" />
<property name="timestampLastMod" type="timestamp" />
</class>
<query name="LastModified.getByResourceId"><![CDATA[
FROM com.foo.bar.LastModified where resourceId=:resourceId]]>
</query>
</hibernate-mapping>
I would like to update our existing hibernate mapping files to enforce a timestamp string representation of YYYY-MM-DD HH24:MI:SS.FF3. I know how to set the NLS_TIMESTAMP_FORMAT using "alter session" or "alter system", but I would like something that handles this at the point the reads and updates are being made, to avoid ambiguity.
Any advice would be greatly appreciated.