-->
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: SaveOrUpdateCopy throwing error on Timestamp field.
PostPosted: Wed Dec 22, 2004 4:10 pm 
Newbie

Joined: Thu Dec 02, 2004 3:51 pm
Posts: 8
Hibernate version:
2.1.7
Mapping documents:
Code:
<class name="com.argus.issueTracker.domain.vo.Issue" table="threads">
        <id name="threadId" column="thread_id" type="integer">
            <generator class="increment"/>
        </id>
        <property name="opened" column="opened" type="timestamp"/>
        <property name="closed" column="closed" type="timestamp"/>
        <property name="lastModified" column="last_modified" type="timestamp"/>
    </class>

Code between sessionFactory.openSession() and session.close():
Code:
try {
            newIssue = (Issue) session.saveOrUpdateCopy(issue);

        } catch (HibernateException e) {
            LOG.error(e);
       

Full stack trace of any exception that occurs:
Code:
java.lang.ClassCastException
   at net.sf.hibernate.type.TimestampType.deepCopyNotNull(TimestampType.java:63)
   at net.sf.hibernate.type.NullableType.deepCopy(NullableType.java:96)
   at net.sf.hibernate.type.TypeFactory.deepCopy(TypeFactory.java:212)
   at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:935)
   at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:866)
   at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:788)
   at net.sf.hibernate.impl.SessionImpl.doCopy(SessionImpl.java:4062)
   at net.sf.hibernate.impl.SessionImpl.saveOrUpdateCopy(SessionImpl.java:4029)
   at com.argus.issueTracker.domain.dao.IssueDAO.createIssue(IssueDAO.java:37)

Name and version of the database you are using:
MySQL


This error occurs when I try to insert a new object into the DB. I am sendign down a populated object to the method excerpt you see above.
Of the 3 Timestamp fields in the DB, all are defined as java.sql.Timestamp's in the java. The Opened field has a default-value of CURRENT-TIMESTAMP in the DB. The rest have a default of 0000-00-00 00:00:00.

I guess I just don't understand what would cause the ClassCast exception. I assume that it's recasting something underneath the hood, but I don't know what, or why?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 22, 2004 4:58 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
what is the type of the underlying resultset column ?

if you don't know then use a debugger to step in and see what it is ,)

_________________
Max
Don't forget to rate


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.