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.  [ 3 posts ] 
Author Message
 Post subject: ClassCastException
PostPosted: Tue Jun 14, 2005 2:46 am 
Newbie

Joined: Sun May 29, 2005 6:32 am
Posts: 4
Hi all.
When I want to load an object, this exception is thrown :

Line is :
role = (Role)session.get(Role.class, inForm.getUsername());

Exception is :

10:33:51,984 INFO [STDOUT] java.lang.ClassCastException
10:33:51,984 INFO [STDOUT] at net.sf.hibernate.type.StringType.toString(StringType.java:47)
10:33:51,984 INFO [STDOUT] at net.sf.hibernate.type.NullableType.nullSafeSet(NullableType.java:
46)
10:33:52,000 INFO [STDOUT] at net.sf.hibernate.type.NullableType.nullSafeSet(NullableType.java:
35)
10:33:52,000 INFO [STDOUT] at net.sf.hibernate.loader.Loader.bindPositionalParameters(Loader.ja
va:674)
10:33:52,000 INFO [STDOUT] at net.sf.hibernate.loader.Loader.prepareQueryStatement(Loader.java:
713)
10:33:52,000 INFO [STDOUT] at net.sf.hibernate.loader.Loader.doQuery(Loader.java:185)
10:33:52,000 INFO [STDOUT] at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollect
ions(Loader.java:133)
10:33:52,000 INFO [STDOUT] at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:836)
10:33:52,000 INFO [STDOUT] at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:856)
10:33:52,000 INFO [STDOUT] at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:59)
10:33:52,016 INFO [STDOUT] at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:51)
10:33:52,016 INFO [STDOUT] at net.sf.hibernate.persister.EntityPersister.load(EntityPersister.j
ava:419)
10:33:52,016 INFO [STDOUT] at net.sf.hibernate.impl.SessionImpl.doLoad(SessionImpl.java:2106)
10:33:52,016 INFO [STDOUT] at net.sf.hibernate.impl.SessionImpl.doLoadByClass(SessionImpl.java:
1980)
10:33:52,016 INFO [STDOUT] at net.sf.hibernate.impl.SessionImpl.internalLoadOneToOne(SessionImp
l.java:1934)
10:33:52,016 INFO [STDOUT] at net.sf.hibernate.type.OneToOneType.resolveIdentifier(OneToOneType
.java:71)
10:33:52,016 INFO [STDOUT] at net.sf.hibernate.type.EntityType.resolveIdentifier(EntityType.jav
a:232)
10:33:52,016 INFO [STDOUT] at net.sf.hibernate.impl.SessionImpl.initializeEntity(SessionImpl.ja
va:2194)
10:33:52,016 INFO [STDOUT] at net.sf.hibernate.loader.Loader.doQuery(Loader.java:240)
10:33:52,016 INFO [STDOUT] at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollect
ions(Loader.java:133)
10:33:52,016 INFO [STDOUT] at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:836)
10:33:52,016 INFO [STDOUT] at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:856)
10:33:52,047 INFO [STDOUT] at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:59)
10:33:52,047 INFO [STDOUT] at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:51)
10:33:52,047 INFO [STDOUT] at net.sf.hibernate.persister.EntityPersister.load(EntityPersister.j
ava:419)
10:33:52,047 INFO [STDOUT] at net.sf.hibernate.impl.SessionImpl.doLoad(SessionImpl.java:2106)
10:33:52,047 INFO [STDOUT] at net.sf.hibernate.impl.SessionImpl.doLoadByClass(SessionImpl.java:
1980)
10:33:52,047 INFO [STDOUT] at net.sf.hibernate.impl.SessionImpl.get(SessionImpl.java:1916)
...
...
...

What is solution of this problem?
Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 14, 2005 5:30 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
The mapping xml (s) would help.
Having said that is the UserName the primary key of Role and a string?


Top
 Profile  
 
 Post subject: This is caused by type mismatch in mapping file
PostPosted: Fri Jun 17, 2005 11:31 pm 
Newbie

Joined: Tue Jan 04, 2005 4:52 pm
Posts: 13
Hi David,

I've seen the same exception before it ocurs when you have a property type set to something other than what the field actually is.

It looks like your mapping file shows one of the properties of Role as 'string' but it is actually something else.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.