-->
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: ClassCastException HashMap not a PersistentCollection
PostPosted: Mon Jan 25, 2010 5:02 pm 
Regular
Regular

Joined: Wed Sep 21, 2005 1:37 pm
Posts: 53
Location: Montpellier - France
Hi,

I'm trying to persist a map but a ClassCastException occurs when trying to count the items (select count suing a native query).

I use the 3.3.0.SP1 release of hibernate core.

The mapping file:
<map name="properties" table="PROPERTIES" lazy="true" mutable="true">
<key column="PKEY" not-null="true" foreign-key="PKEY" />
<map-key type="java.lang.String" column="NAME" length="64" />
<element column="VALUE" type="java.lang.String" length="255" not-null="false" />
</map>
<component name="licenses" lazy="false" class="LicensesImpl">
<map name="values" table="LICENSES" lazy="false" mutable="true">
<key column="PKEY" not-null="true" foreign-key="PKEY" />
<map-key column="FEATURE" type="java.lang.String" length="32" />
<element column="VALUE" type="java.lang.Boolean" not-null="false" />
</map>
</component>

The properties seems to be ok (I have tried without it) but not the licenses.

The exception is described below:
Caused by: java.lang.ClassCastException: java.util.HashMap cannot be cast to org.hibernate.collection.PersistentCollection
at org.hibernate.event.def.DirtyCollectionSearchVisitor.processCollection(DirtyCollectionSearchVisitor.java:74)
at org.hibernate.event.def.AbstractVisitor.processValue(AbstractVisitor.java:124)
at org.hibernate.event.def.AbstractVisitor.processValue(AbstractVisitor.java:84)
at org.hibernate.event.def.AbstractVisitor.processValues(AbstractVisitor.java:63)
at org.hibernate.event.def.AbstractVisitor.processComponent(AbstractVisitor.java:105)
at org.hibernate.event.def.AbstractVisitor.processValue(AbstractVisitor.java:130)
at org.hibernate.event.def.AbstractVisitor.processValue(AbstractVisitor.java:84)
at org.hibernate.event.def.AbstractVisitor.processEntityPropertyValues(AbstractVisitor.java:78)
at org.hibernate.event.def.DefaultFlushEntityEventListener.hasDirtyCollections(DefaultFlushEntityEventListener.java:451)
at org.hibernate.event.def.DefaultFlushEntityEventListener.isUpdateNecessary(DefaultFlushEntityEventListener.java:439)
at org.hibernate.event.def.DefaultFlushEntityEventListener.isUpdateNecessary(DefaultFlushEntityEventListener.java:228)
at org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:150)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:219)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:99)
at org.hibernate.event.def.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:58)
at org.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:996)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1141)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)
at org.hibernate.ejb.QueryImpl.getSingleResult(QueryImpl.java:88)

Thanks.


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.