-->
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: Annotation mapping SortedMap<Integer, Double> problem
PostPosted: Sun Dec 09, 2007 4:00 pm 
Newbie

Joined: Sun Dec 09, 2007 3:42 pm
Posts: 4
Location: Italy
I try to get a fairly simple mapping for a TreeMap to work:

Code:
   @org.hibernate.annotations.CollectionOfElements
   @JoinTable(
         name = "cbs_hour_quotes",
         joinColumns = {@JoinColumn(name = "cbs_id")}
         )
   @MapKey(name = "year")
   @Column(name = "quote")
   @org.hibernate.annotations.Sort(type = org.hibernate.annotations.SortType.NATURAL)
   private SortedMap<Integer, Double> quotes;


I expext as result a table named cbs_hour_quotes with 3 colums cbs_id, year and quote.

Instead i get the following exception:
Code:
Caused by: org.hibernate.AnnotationException: Associated class not found: java.lang.Double
   at org.hibernate.cfg.annotations.MapBinder.bindKeyFromAssociationTable(MapBinder.java:100)
   at org.hibernate.cfg.annotations.MapBinder.access$000(MapBinder.java:53)
   at org.hibernate.cfg.annotations.MapBinder$1.secondPass(MapBinder.java:83)
   at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:43)
   at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1130)
   at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:316)
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1286)
   at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:915)
   at it.atsf.draft.persistence.HibernateUtil.<clinit>(HibernateUtil.java:17)
   ... 32 more



Any idea what's wrong? Why is it not possible to map a basic Double type?

Environment:
JDK 1.6
Hibernate 3.2.4.ga
Annotations 3.3.0.ga


Top
 Profile  
 
 Post subject: Looks like a bug - Applied workaround
PostPosted: Mon Dec 10, 2007 9:40 am 
Newbie

Joined: Sun Dec 09, 2007 3:42 pm
Posts: 4
Location: Italy
I played around a bit with this, searched forums and net - and gave up

I believe there is a bug with the annotation mapping for a SortedMap (couldn't even find a test for it in the hibernate-annotations tests).

My current solution is to use a simple Map instead.

Code:
   @org.hibernate.annotations.CollectionOfElements(
         targetElement = java.lang.Double.class,
         fetch = FetchType.EAGER)
   @JoinTable(
         name = "cbs_hour_quotes",
         joinColumns = {@JoinColumn(name = "cbs_id")})
   @org.hibernate.annotations.Sort(type = org.hibernate.annotations.SortType.NATURAL)
   private Map<Integer, Double> quotes = new TreeMap<Integer, Double>();


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 14, 2008 3:43 pm 
Newbie

Joined: Tue Oct 14, 2008 3:08 pm
Posts: 8
Location: Brasil
Hi, people!

I got a simple Map mapping working here after removing the JPA @MapKey annotation. I think it was the problem on the initial post annotation, not any related with the TreeMap..

My full config is:
Code:
@CollectionOfElements
@JoinTable(
      name = "vendaveis_respostas_valores",
      joinColumns = {@JoinColumn(name = "associacao_id")}
      )
@Column(name = "valor")
@org.hibernate.annotations.MapKey(columns = {@Column(name="resposta")})
private Map<String, Double> valorRespostas;


I could set the column name of the key only with the hibernate annotation...

I'm using Hibernate 3.2.6.ga and annotations 3.3.1.ga

_________________
Bruno Medeiros


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.