Hibernate version: 3
Mapping documents:
Code between sessionFactory.openSession() and session.close():
public T save(T entity)
{
Session session = getSessionFactory().getCurrentSession();
try
{
session.save(entity);
}
catch (HibernateException ex)
{
SessionFactoryUtils.convertHibernateAccessException(ex);
}
return entity;
}
Full stack trace of any exception that occurs:
Name and version of the database you are using:
Oracle 10x
The generated SQL (show_sql=true): Cannot view this, can I???
Debug level Hibernate log excerpt:
Hey, this is obviously my first post. I couldn't find the FAQ for the forum, sorry, if this has been covered I will certainly go there when someone points me to it...
I am working on an application that uses Hibernate. We used middlegen to create the .hbm files for all the tables in our DB schema. Hibernate then gens the pojo's for the entities we use to persist the data. In the mapping files all Oracle date columns are mapped to java.sql.Date. In the pojo's that hibernate creates all dates fields are java.util.Date. We have a seperate util class that simply gens the current GMT date as a java.util.Date that we put into the pojo dates. This has all been verified and works.
In the sample method above the T entity is a hibernate-genned pojo.
The problem is that in the sample code, when the Session.save() method is called and the object is saved to the Oracle table, the date is truncated, ie, missing the TIME portion of the date. I have verified that when the date is SET in the pojo that it is a Long date and the fast time jives up with what was created in my util class.
Somehow when HibernateDAOSupport or whatever does the insert or update, the TIME portion of the date is lost. So doing a:
SELECT TO_CHAR(MY_DATE_COLUMN, 'DD-MON-YYYY HH24:MI:SS') FROM MY_TABLE;
returns (for example): 28-DEC-2006 00:00:00
Does anyone have any idea or experience as to why this is happening??? TIA!
|