-->
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 with Map and binary
PostPosted: Fri Apr 16, 2004 11:08 am 
Regular
Regular

Joined: Thu Feb 05, 2004 6:51 am
Posts: 50
Hi all,

I have a Class HibernateDataEventAudit with a Map (HashMap) newData which contains String as key and Object (can't know which type at development time).

So I have set the following mapping with Hibernate 2.1.1 :
<joined-subclass name="HibernateDataEventAudit" table="dataeventaudits"> (PostgreSQL)
<key column="id"/>
<map name="newData" table="neweventauditdata">
<key column="dataeventaudit"/>
<index column="variabledefinitionid" type="string"/>
<element column="variablevalue" type="binary"/>
</map>
</joined-subclass>

I'm sure that at runtime, the map to be persited is not null :
CREATE TABLE "neweventauditdata" (
"dataeventaudit" numeric(19,0) NOT NULL,
"variabledefinitionid" character varying(254) NOT NULL,
"variablevalue" bytea NOT NULL)
I get and ClassCast :
java.lang.ClassCastException
at net.sf.hibernate.type.BinaryType.set(BinaryType.java:28)
at net.sf.hibernate.type.NullableType.nullSafeSet(NullableType.java:48)
at net.sf.hibernate.type.NullableType.nullSafeSet(NullableType.java:35)
at net.sf.hibernate.collection.AbstractCollectionPersister.writeElement(AbstractCollectionPersister.java:384)
at net.sf.hibernate.collection.Map.writeTo(Map.java:194)
at net.sf.hibernate.collection.AbstractCollectionPersister.recreate(AbstractCollectionPersister.java:537)
at net.sf.hibernate.impl.ScheduledCollectionRecreate.execute(ScheduledCollectionRecreate.java:23)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2308)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2265)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2187)
at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:61)


I have tried to set the column variable value to character varying but the same exception occurs.

Any Idea


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 16, 2004 11:12 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
binary is for persisting byte[] propertys, are you really having one of those?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 16, 2004 12:00 pm 
Regular
Regular

Joined: Thu Feb 05, 2004 6:51 am
Posts: 50
Thanks for so quick response, it was an object type. I thought it would be alright, I serialise it and it works.

Vlad


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.