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