-->
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.  [ 2 posts ] 
Author Message
 Post subject: Classcast Exception from Loader
PostPosted: Mon Sep 08, 2003 6:38 am 
Newbie

Joined: Mon Sep 08, 2003 4:24 am
Posts: 1
I'm new to Hibernate so possibly I am doing something terribly wrong or haven't read the manual correctly.

I receive the following Classcast exception:
Code:
java.lang.ClassCastException: org.wmt.pdc.KZPContractPartner
  at net.sf.hibernate.loader.Loader.getKeyFromResultSet(Loader.java:219)
  at net.sf.hibernate.loader.Loader.doFind(Loader.java:154)
  at net.sf.hibernate.loader.Loader.find(Loader.java:620)
  ...

I use the following mapping :
Code:
<class name='org.wmt.pdc.KZPContractPartner' table='WMT_KONTRAKTPARTNER'>
  <composite-id>
    <key-property name='idCp' column='ID_KV'/>
    <key-property name='numberClientWmt' column='NUM_CLIENT'/>
    <key-property name='numberMainClient' column='NUM_MAIN_CLIENT'/>
  </composite-id>
</class>


with the Java class KZPContractPartner:

Code:
private String idCp;
private String numberMainClient;
private String numberClientWmt;
with the appropriate getters and setters.

The table is defined in MySQL as
Code:
WMT_KONTRAKTPARTNER
ID_KV             DECIMAL(11,0)       PK
NUM_CLIENT  DECIMAL(11,0)       PK
NUM_MAIN_CLIENT DECIMAL(11,0) PK


Do I miss something here?

Thanks in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 08, 2003 6:48 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
A class with an "embedded" composite id is required to implement Serializable, equals() and hashCode(). I *strongly* recommend you split out the composite id into a seperate class. It is much more elegant that way.


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

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.