Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Hibernate and Date objects

1 view
Skip to first unread message

Chris Williams

unread,
Jan 9, 2005, 11:07:39 PM1/9/05
to
Hi everyone,


I'm having a frustrating time working with Date objects and Hibernate
with an Oracle database.

I have a Patient class containing a Date field (java.util.Date)

and the mapping in the hbm.xml file:

<property name="regDate" type="date">
<column name="REGISTRATION_DATE" />
</property>

When I try and commit a new object to the database, I get a
ClassCastException with the following backtrace:

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.save(SessionImpl.java:747)
at com.sleep.PatientHandler.doPost(PatientHandler.java:96)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:825)
at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:731)
at
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:526)
at
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:534)


Is this something to do with casting (and failing) an java.sql.Date to a
java.util.Date or something similar?

If anyone can shed any light on this, or has had a similar problem, it
would be greatly appreciated!


Cheers,

Chris.


btbven

unread,
Feb 12, 2005, 12:50:28 AM2/12/05
to
Hi Chris

I am facing the same problem at the moment. Have you been able to find a
solution? If you can please let me know.

thanks,
bt.


Gene Mayfield via JavaKB.com

unread,
Mar 2, 2005, 4:12:54 PM3/2/05
to
Same Here: If anybody finds a solution. It's giving me a Typecast error on
test.

Thanks

--
Message posted via http://www.javakb.com

0 new messages