映射地图< String,Double>与Hibernate和JPA [英] Mapping a Map<String, Double> with Hibernate and JPA
问题描述
我尝试以下映射:
@ElementCollection
私人地图< String,Double> doubleValues;
但是,当我从此生成我的模式时(使用 mvn hibernate3:hbm2ddl ),我得到以下错误:
org.hibernate.MappingException:无法确定类型为:java.util.Map, at table:ImagerAnalysisResult,for columns:[org.hibernate.mapping.Column(doubleValues)]
I已经尝试向此添加列和类型信息,但我一直得到相同的错误。另外,我不认为应该给出信息,因为hibernate应该使用泛型声明(根据如何映射Map< String,Double> )。
我使用的是hibernate 3.6.4.Final,尝试过其他版本
有什么建议吗?感谢。
编辑:看起来maven hibernate插件已经两年了,并且依赖于旧的hibernate版本...为什么这个插件没有被维护? p>
编辑:命名字段doubleValues以确保没有保留名称问题。
@ElementCollection
@CollectionTable(name = MY_ENTITY_VALUES,joinColumns = @JoinColumn(name =entity_id))
@Column(name =DOUBLE_VALUES)
私人地图< String,Double> doubleValues;
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.
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;
这篇关于映射地图< String,Double>与Hibernate和JPA的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!