-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Hibernate to Oracle dropping date-time precision
PostPosted: Thu Dec 28, 2006 5:20 pm 
Newbie

Joined: Thu Dec 28, 2006 5:02 pm
Posts: 2
Location: Atlanta, GA
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!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 29, 2006 1:10 pm 
Newbie

Joined: Thu Dec 28, 2006 5:02 pm
Posts: 2
Location: Atlanta, GA
Nevermind, I finally found THIS thread: http://forum.hibernate.org/viewtopic.php?t=927602

Thanks anyways...


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.