-->
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: MappingException: Could not instantiate comparator class
PostPosted: Thu Jul 02, 2009 5:26 am 
Regular
Regular

Joined: Fri May 22, 2009 4:50 am
Posts: 59
Hi All,

I am having problem with sort mapping for comparator class which is not an inerr class in my class.
But for some reason I am getting the org.hibernate.MappingException: Could not instantiate comparator class exception for following mapping.

My comparator class is a simple java class:

my mapping for sort is as follows:
public class Money extends Comparable<Money> {

---other implementation code goes here

public int compareTo(Money money) {
return value.compareTo(money.value);
}
}

<map name="entries" table="bid_values" lazy="false" sort="com.app.type.Money" cascade="all">
<key column="id"/>
<index column="price"/>
<composite-element class="com.app.model.Entry">
<property name="volume" column="volume"/>
<property name="price" column="price"/>
</composite-element>
</map>

I dont see any reason for the excpetion. Can any please put some light on it.

any help appreciated!

cheers!!


Top
 Profile  
 
 Post subject: Re: MappingException: Could not instantiate comparator class
PostPosted: Thu Jul 02, 2009 11:55 am 
Regular
Regular

Joined: Fri Jan 30, 2009 10:10 am
Posts: 74
Location: London
A couple of things to consider
- is there anything about your Money class that could make it difficult to instantiate using reflection?
- a Comparator should provide a:
Code:
public int compare(Object o1, Object o2)

method, not the compareTo that you have shown in your code sample.
(You may have confused Comparator with Comparable)


--
Stephen Souness


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.