-->
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: java.lang.ClassCastException:
PostPosted: Tue Jun 09, 2009 2:23 am 
Newbie

Joined: Tue Jun 09, 2009 1:34 am
Posts: 6
Location: india
Hi, I am getting problem while inserting the data into the data base. Following is the complete information of what I am doing for the mapping the table. Please! Guide me porperly ....
The mapping should be one-to-many (uni direction or bi direction what ever may be but it should be work for that)

Code:

[quote]hibernate.cfg.xml[/quote]
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
                                         "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
      <property name="hibernate.connection.url">jdbc:oracle:thin:@localhost:1521:student</property>
      <property name="hibernate.connection.username">student</property>
      <property name="hibernate.connection.password">student</property>
      <property name="hibernate.connection.pool_size">10</property>
      <property name="show_sql">true</property>
      <property name="dialect">org.hibernate.dialect.OracleDialect</property>
      <property name="hibernate.hbm2ddl.auto">update</property>
      <!-- Mapping files -->
  <mapping resource="license.hbm.xml"/>
  <mapping resource="feature.hbm.xml"/> 
  <mapping resource="targetsystem.hbm.xml"/>
</session-factory>
</hibernate-configuration>

[quote]license.hbm.xml[/quote]

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
   "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
   "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.hibernate.licensing.mapping" >
  <class name="License" table="LICENSE">
  <id name="serialNbr" column="SERIALNUMBER" type="string">
  <generator class="assigned"/>
  </id> 
  <property name="licenseName" column="LICENSENAME" type="string"/>
  <property name="customerId" column="CUSTOMERID" type="string"/>
  <property name="licenseType" column="LICENSETYPE" type="string"/>
  <property name="maxValue" column="LICMAXVALUE" type="int"/>
  <property name="startTime" column="STARTTIME" type="date"/>
  <property name="endTime" column="ENDTIME" type="date"/>
  <property name="capacityUnit" column="CAPACITYUNIT" type="string"/>
  <property name="licenseFileName" column="LICENSEFILENAME" type="string"/>
  <property name="isValid" column="ISVALID" type="string"/>
  <property name="licenseSignature" column="LICENSESIGNATURE" type="binary"/>
 
  <list name="featureInfoList" table="FEATURE" cascade="delete">
  <key column="SERIALNUMBER"/>
  <index column="id"/>
  <one-to-many class="com.hibernate.licensing.mapping.Feature"/>
  </list>
 
  <list name="targetIds" table="TARRGETSYSTEM" cascade="delete">
  <key column="SERIALNUMBER"/>
  <index column="id"/>
  <one-to-many  class="com.hibernate.licensing.licensing.mapping.TargetSystem"/>
  </list>
 
  </class> 
   
</hibernate-mapping>

[quote]feature.hbm.xml[/quote]

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
   "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
   "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.hibernate.licensing.mapping">
  <class name="Feature" table="FEATURE">
  <id name="id" column="ID" type="int">
  <generator class="sequence"/>
  </id>
  <property name="serialNbr" column="SERIALNUMBER" type="string"/>
  <property name="featureCode" column="FEATURECODE" type="long"/>
  <property name="featureInfoSignature" column="FEATURESIGNATURE" type="binary"/>
  </class>
</hibernate-mapping>

[quote]targetsystem.hbm.xml[/quote]


<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
   "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
   "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.hibernate.licensing.mapping"> 
  <class name="TargetSystemBean" table="TARGETSYSTEM">
  <id name="id" column="ID" type="int">
  <generator class="sequence"/>
  </id>
  <property name="serialNbr" column="SERIALNUMBER" type="string"/>
  <property name="targetId" column="TARGET" type="string"/>
  <property name="targetSystemSignature" column="TARGRTSYSTEMSIGNATURE" type="binary"/>
  </class> 
</hibernate-mapping>

<error>


java.lang.ClassCastException: com.hibernate.licensing.mapping.Feature
   at org.hibernate.type.EntityType.toLoggableString(EntityType.java:134)
   at org.hibernate.type.CollectionType.toLoggableString(CollectionType.java:143)
   at org.hibernate.pretty.Printer.toString(Printer.java:53)
   at org.hibernate.pretty.Printer.toString(Printer.java:90)
   at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:91)
   at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26)
   at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:678)
   at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:309)
   at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:86)
   at com.hibernate.licensing.impl.LicenseImpl.insertLicenseInformation(LicenseImpl.java:92)
   at com.hibernate.licensing.impl.LicenseImplTest.testInsertLicenseInformation(LicenseImplTest.java:126)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:585)
   at junit.framework.TestCase.runTest(TestCase.java:154)
   at junit.framework.TestCase.runBare(TestCase.java:127)
   at junit.framework.TestResult$1.protect(TestResult.java:106)
   at junit.framework.TestResult.runProtected(TestResult.java:124)
   at junit.framework.TestResult.run(TestResult.java:109)
   at junit.framework.TestCase.run(TestCase.java:118)
   at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
   at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
com.hibernate.licensing.mapping.Feature
</error>




The code is working for without mapping in license.hbm.xml (i.e list tags are removed), but mapping should be there .................


can any one pls help me as early as possible ...............

_________________
Ram


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.