-->
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: problem persisting java.util.TreeMap in hibernate
PostPosted: Wed Jul 01, 2009 12:19 pm 
Regular
Regular

Joined: Fri May 22, 2009 4:50 am
Posts: 59
Hi,
I am just not able to understand the reason for getting following error while saving my java TreeMap using hibernate.
My hibernate mapping is

<map name="entries" table="bid_values" lazy="false" sort="natural">
<key column="ID" />
<index column="price"/>
<composite-element class="Entry">
<property name="type" column="type"/>
<property name="volume" column="volume"/>
</composite-element>
</map>


And error and exception is as follows:

16:05:23.552 [Thread-3] ERROR o.h.property.BasicPropertyAccessor expected type: java.util.TreeMap, actual value: org.hibernate.collection.PersistentSortedMap
org.springframework.orm.hibernate3.HibernateSystemException: IllegalArgumentException occurred while calling setter of entries; nested exception is org.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of com.miriamlaurel.fi.protocol.model.Quote.bidEntries
at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:661)
at org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412)
at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:424)
at org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374)
at org.springframework.orm.hibernate3.HibernateTemplate.saveOrUpdate(HibernateTemplate.java:744)
at com.miriamlaurel.blackjack.server.services.DataManager.storeOrder(DataManager.java:101)
at com.miriamlaurel.fi.protocol.model.Market.onQuote(Market.java:170)
at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.miriamlaurel.pms.listeners.dispatch.DispatchListener.invoke(DispatchListener.java:171)
at com.miriamlaurel.pms.listeners.dispatch.DispatchListener.processMessage(DispatchListener.java:111)
at com.miriamlaurel.pms.listeners.MessageListenerDelegate.processMessage(MessageListenerDelegate.java:40)
at com.miriamlaurel.blackjack.maya.MockFeedEmitter.run(MockFeedEmitter.java:159)
Caused by: org.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of com.miriamlaurel.fi.protocol.model.Quote.bidEntries
at org.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:128)
at org.hibernate.tuple.entity.AbstractEntityTuplizer.setPropertyValues(AbstractEntityTuplizer.java:360)
at org.hibernate.tuple.entity.PojoEntityTuplizer.setPropertyValues(PojoEntityTuplizer.java:221)
at org.hibernate.persister.entity.AbstractEntityPersister.setPropertyValues(AbstractEntityPersister.java:3594)
at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:300)
at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:204)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:144)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:210)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:195)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:117)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:93)
at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:534)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:526)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:522)
at org.springframework.orm.hibernate3.HibernateTemplate$16.doInHibernate(HibernateTemplate.java:747)
at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:419)
... 11 more
Caused by: java.lang.IllegalArgumentException: argument type mismatch
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:597)
at org.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:66)
... 26 more

any help appreciated!

cheers!


Top
 Profile  
 
 Post subject: Re: problem persisting java.util.TreeMap in hibernate
PostPosted: Wed Jul 01, 2009 12:45 pm 
Regular
Regular

Joined: Fri May 22, 2009 4:50 am
Posts: 59
just wanted to mention that same thing with java.util.Map works absolutely fine but it just dsnt work with TreeMap.

Kindly help!


Top
 Profile  
 
 Post subject: Re: problem persisting java.util.TreeMap in hibernate
PostPosted: Wed Jul 01, 2009 1:26 pm 
Regular
Regular

Joined: Fri May 22, 2009 4:50 am
Posts: 59
hey i have got the answer to my problem..

providing comparable class for keys of treeMap is must! one should provide that in sorted="class name" attribute of map.
I knew it was required but i waited just as to check if my mapping in hibernate was correct. i shouldn't hv! ;)


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.