Hi,
I tried a standalone testcase and it worked for me in 8i.
The entity code is as follows :
Code:
import java.util.Date;
public class MyEntity
{
private long id;
private Date date;
// ... getters and setters for these two properties
}
It is mapped as :
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping package="tavant.platform.persistence.hibernate.date">
<class name="MyEntity" table="MY_ENTITY">
<id name="id" column="MY_ID" type="long">
<generator class="native"/>
</id>
<property name="date" column="MY_DATE" type="timestamp"/>
</class>
</hibernate-mapping>
And I use a test to try out the mapping :
Code:
public class Test
{
public static void main(String[] args) throws Exception
{
Session session = new Configuration()
.addClass(MyEntity.class)
.buildSessionFactory()
.openSession();
System.out.println("Openend Session");
Transaction transaction = session.beginTransaction();
System.out.println("Started Transaction");
MyEntity e = new MyEntity();
e.setDate(new Date());
System.out.println("Created Transient Entity");
session.save(e);
transaction.commit();
System.out.println("Persisted Entity");
session.close();
}
}
It works well, and inserts the entity correctly.
Code:
SQL> desc my_entity;
Name Null? Type
----------------------------------------- -------- ----------------------------
MY_ID NOT NULL NUMBER(19)
MY_DATE DATE
SQL> select my_id, to_char(my_date, 'DD/MM/YY HH24-MI-SS') from my_entity;
MY_ID TO_CHAR(MY_DATE,'
---------- -----------------
27 11/08/04 21-05-27
Try this simple code on 9i, and see if it works.