4

I try the following mapping

@ElementCollection
private Map<String, Double> doubleValues;

But when I generate my schema from this (using mvn hibernate3:hbm2ddl), I get the following errors:

org.hibernate.MappingException: Could not determine type for: java.util.Map, at table: ImagerAnalysisResult, for columns: [org.hibernate.mapping.Column(doubleValues)]

I've tried adding column and type information to this, but I keep getting the same error. Also, I don't think that information should be given as hibernate should use the generic declaration (according to How to map a Map<String,Double>).

I'm using hibernate version 3.6.4.Final and I've tried other versions

Any suggestions? Thanks.

Edit: it appears that the maven hibernate plugin is two years old and depends on an older hibernate version... why is this plugin not being maintained?

Edit: named field "doubleValues" to make sure there's no reserved-name-issue.

Community
  • 1
  • 1
Wouter Lievens
  • 4,019
  • 5
  • 41
  • 66

2 Answers2

0

The word "values" is a SQL reserved keyword and you cannot use it for an identifier in SQL. The same thing would haven if you try to name something "index". If you change the name to something else it should work.

You know:

insert into table values (...)

I've had similar issues in the past while autogenerating code due to the use of other keywords too.

By the way, in the past I experimented several issues with Hibernate 3.6.2 and map collections. You might like to take a look a this answer, since you seem to be heading the same way.

I hope that helps!

Community
  • 1
  • 1
Edwin Dalorzo
  • 76,803
  • 25
  • 144
  • 205
  • Actually my field is named differently. The error is completely independent of the field's name. Sorry for the confusion; I will amend the question. – Wouter Lievens May 23 '11 at 12:25
0

You can try to be more explicit:

@ElementCollection
@CollectionTable(name = "MY_ENTITY_VALUES", joinColumns = @JoinColumn(name = "entity_id"))
@Column(name = "DOUBLE_VALUES")
private Map<String, Double> doubleValues;
Teg
  • 1,302
  • 13
  • 32