-->
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.  [ 1 post ] 
Author Message
 Post subject: Problem with DateTime
PostPosted: Tue Jun 22, 2004 11:17 am 
Beginner
Beginner

Joined: Tue Mar 02, 2004 1:12 pm
Posts: 25
Location: Newcastle Upon Tyne
Hi Again,

I have a mapping which is as follows:

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>
   <class name="uk.org.mygrid.infomodel.ExperimentInstance" table="experimentinstance">
      <id name="LSID" type="java.lang.String" column="experimentinstance_id">
         <generator class="assigned"/>
      </id>
      <property name="name" type="java.lang.String" column="name" length="50"/>
      <property name="description" type="java.lang.String" column="description" length="80"/>
      <property name="startTime" type="java.util.Calendar" column="startTime"/>
      <property name="endTime" type="java.util.Calendar" column="endTime"/>
      <property name="status" type="java.lang.String" column="status" length="10"/>
      <property name="metadataLSID" type="java.lang.String" column="metadataLSID" length="80"/>
      <!-- associations -->
      <!-- one-to-one association to OperationTrace -->
      <many-to-one name="operationtrace" class="uk.org.mygrid.infomodel.OperationTrace" column="operationtrace_id" unique="true" cascade="all"/>      
      <!-- one-to-one association to ScuflWorkflowTrace -->
      <many-to-one name="scuflworkflowtrace" class="uk.org.mygrid.infomodel.ScuflWorkflowTrace" column="scuflworkflowtrace_id" unique="true" cascade="all"/>      
   </class>
</hibernate-mapping>


I am using hibernate 2.1.2, MySql 4.0 and JDK 1.4.2. I have seen in the hibernate documentation that java.util.Calendar is mapped to TIMESTAMP (section 5.2.2). So I have initialized the Calendar field with Calendar.getInstance method. But I am getting an exception while trying to save this object:

Code:
     [java] java.lang.ClassCastException
     [java] 16:04:29,565 DEBUG MyGridLSIDDataService:152 - Assgined LSID: urn:lsid:mygrid.org.uk:experimentinstance:4ce2fa7d80f094ea01e67e6a67bceb27
     [java]     at net.sf.hibernate.type.DateType.deepCopyNotNull(DateType.java:67)
     [java]     at net.sf.hibernate.type.NullableType.deepCopy(NullableType.java:96)
     [java]     at net.sf.hibernate.type.TypeFactory.deepCopy(TypeFactory.java:212)
     [java] 16:04:29,565 DEBUG SessionImpl:807 - saving [uk.org.mygrid.infomodel.ExperimentInstance#urn:lsid:mygrid.org.uk:experimentinstance:4ce2fa7d
80f094ea01e67e6a67bceb27]
     [java]     at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:900)
     [java]     at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:839)
     [java] 16:04:29,565 DEBUG Cascades:497 - processing cascades for: uk.org.mygrid.infomodel.ExperimentInstance
     [java] 16:04:29,565 DEBUG Cascades:506 - done processing cascades for: uk.org.mygrid.infomodel.ExperimentInstance
     [java]     at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:793)
     [java]     at uk.org.mygrid.mir.service.DataAccess.StoreEntity(DataAccess.java:80)
     [java] 16:04:29,612 ERROR DataAccess:84 - Error storing object in database
     [java]     at uk.org.mygrid.mir.domain.ExperimentInstanceMgr.add(ExperimentInstanceMgr.java:34)
     [java] java.lang.ClassCastException
     [java]     at uk.org.mygrid.mir.domain.ExperimentDesignMgr.createExperimentInstances(ExperimentDesignMgr.java:116)
     [java]     at uk.org.mygrid.mir.domain.ExperimentDesignMgr.add(ExperimentDesignMgr.java:28)
     [java]     at net.sf.hibernate.type.DateType.deepCopyNotNull(DateType.java:67)
     [java]     at net.sf.hibernate.type.NullableType.deepCopy(NullableType.java:96)
     [java]     at uk.org.mygrid.mir.service.MIRAccessServiceBindingImpl.storeMIREntity(MIRAccessServiceBindingImpl.java:91)
     [java]     at net.sf.hibernate.type.TypeFactory.deepCopy(TypeFactory.java:212)
     [java]     at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:900)
     [java]     at uk.org.mygrid.mir.test.ServiceTest.createExperiment(ServiceTest.java:378)
     [java]     at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:839)
     [java]     at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:793)
     [java]     at uk.org.mygrid.mir.test.ServiceTest.main(ServiceTest.java:468)
     [java]     at uk.org.mygrid.mir.service.DataAccess.StoreEntity(DataAccess.java:80)
     [java]     at uk.org.mygrid.mir.domain.ExperimentInstanceMgr.add(ExperimentInstanceMgr.java:34)
     [java]     at uk.org.mygrid.mir.domain.ExperimentDesignMgr.createExperimentInstances(ExperimentDesignMgr.java:116)
     [java]     at uk.org.mygrid.mir.domain.ExperimentDesignMgr.add(ExperimentDesignMgr.java:28)
     [java]     at uk.org.mygrid.mir.service.MIRAccessServiceBindingImpl.storeMIREntity(MIRAccessServiceBindingImpl.java:91)
     [java]     at uk.org.mygrid.mir.test.ServiceTest.createExperiment(ServiceTest.java:378)
     [java]     at uk.org.mygrid.mir.test.ServiceTest.main(ServiceTest.java:468)


Can anyone please help me? I found only two topics in the forum which are similar, and one was posted just yesterday...looking forward to some suggestions.

Thanx in advance...

Arijit


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

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.