| Author |
Class Cast Exception
|
James Dsouza
Greenhorn
Joined: Nov 28, 2006
Posts: 2
|
|
Hi All, I facing a problem with this mapping file. Hibernate 3.2.3 <hibernate-mapping> <class name="com.thbs.induction.bo.InductionTaskMap" table="induction_task_map"> <composite-id> <key-property name="parentTaskId" type="integer"/> <key-property name="childTaskId" type="integer"/><key-property name="sequence" type="integer"/> </composite-id> <property name="parentTaskId" type="integer" insert="false" update="false" access="field"/> =========> ( 1 ) <bag name="children" table="induction_task_map" order-by="sequence asc" lazy="false"> <key property-ref="parentTaskId" /> <one-to-many class="com.thbs.induction.bo.InductionTaskMap"/> </bag> </class> <query name="InductionTaskMap.findByParentId"> <![CDATA[select taskMap from InductionTaskMap taskMap where taskMap.parentTaskId = ? ]]> </query> </hibernate-mapping> Please have a look at the property tag at ( 1 ). If I remove this I get a this exception -------------------------------------- Caused by: org.hibernate.MappingException: Same physical column represented by different logical column names: induction_task_map.parent_task_id => 'parentTaskId' and 'parent_task_id' at org.hibernate.cfg.Mappings.addColumnBinding(Mappings.java:464) at org.hibernate.cfg.HbmBinder.bindColumns(HbmBinder.java:1075) at org.hibernate.cfg.HbmBinder.bindColumnsOrFormula(HbmBinder.java:1518) at org.hibernate.cfg.HbmBinder.bindSimpleValue(HbmBinder.java:1124) at org.hibernate.cfg.HbmBinder.bindCollectionSecondPass(HbmBinder.java:2405) at org.hibernate.cfg.HbmBinder$CollectionSecondPass.secondPass(HbmBinder.java:2652) at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:43) at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1130) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1286) at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:805) at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:745) ---------------------- To solve the above problem I added a property-ref attribute to my collection.This solved my above problem with a new exception shown below I am new to hibernate.Please help!! Stacktrace ------------- java.lang.ClassCastException: java.lang.Integer at org.hibernate.type.ComponentType.toLoggableString(ComponentType.java:377) at org.hibernate.pretty.MessageHelper.collectionInfoString(MessageHelper.java:284) at org.hibernate.loader.Loader.loadCollection(Loader.java:2001) at org.hibernate.loader.collection.CollectionLoader.initialize(CollectionLoader.java:36) at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:565) at org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:60) at org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1716) at org.hibernate.collection.AbstractPersistentCollection.forceInitialization(AbstractPersistentCollection.java:454) at org.hibernate.engine.StatefulPersistenceContext.initializeNonLazyCollections(StatefulPersistenceContext.java:785) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:241) at org.hibernate.loader.Loader.doList(Loader.java:2220) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104) at org.hibernate.loader.Loader.list(Loader.java:2099) at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:378) at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:338) at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172) at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121) at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79) at com.thbs.induction.framework.dataaccess.hibernate.impl.GenericDaoHibernateImpl.executeFinder(GenericDaoHibernateImpl.java:144) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) -------------
|
 |
 |
|
|
subject: Class Cast Exception
|
|
|