Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/hibernate/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java &引用;非法尝试将非集合映射为@OneToMany、@ManyToMany或@CollectionFelements“;在hibernate中注释ConcurrentHashMap时_Java_Hibernate - Fatal编程技术网

Java &引用;非法尝试将非集合映射为@OneToMany、@ManyToMany或@CollectionFelements“;在hibernate中注释ConcurrentHashMap时

Java &引用;非法尝试将非集合映射为@OneToMany、@ManyToMany或@CollectionFelements“;在hibernate中注释ConcurrentHashMap时,java,hibernate,Java,Hibernate,我已尝试注释返回值为映射的属性访问器,如下所示: @MapKeyColumn(name="parameter_name") @ElementCollection public ConcurrentHashMap<String, Serializable> getParameterValues() @MapKeyColumn(name=“parameter\u name”) @元素集合 公共ConcurrentHashMap getParameterValues() 这符合hibe

我已尝试注释返回值为映射的属性访问器,如下所示:

@MapKeyColumn(name="parameter_name")
@ElementCollection
public ConcurrentHashMap<String, Serializable> getParameterValues()
@MapKeyColumn(name=“parameter\u name”)
@元素集合
公共ConcurrentHashMap getParameterValues()
这符合hibernate用户指南(第2.2.5.3.4节)。然而,我得到:

org.hibernate.AnnotationException: Illegal attempt to map a non collection as a @OneToMany, @ManyToMany or @CollectionOfElements: ConfigurationParameterBag.parameterValues
at org.hibernate.cfg.annotations.CollectionBinder.getCollectionBinder(CollectionBinder.java:324)
at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:1723)
at org.hibernate.cfg.AnnotationBinder.processIdPropertiesIfNotAlready(AnnotationBinder.java:796)
at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:707)
at org.hibernate.cfg.Configuration$MetadataSourceQueue.processAnnotatedClassesQueue(Configuration.java:4035)
at org.hibernate.cfg.Configuration$MetadataSourceQueue.processMetadata(Configuration.java:3989)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1398)
at org.hibernate.cfg.Configuration.generateDropSchemaScript(Configuration.java:1002)
at org.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:130)
at org.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:92)
org.hibernate.AnnotationException:非法尝试将非集合映射为@OneToMany、@ManyToMany或@CollectionOffElements:ConfigurationParameterBag.parameterValues
位于org.hibernate.cfg.annotations.CollectionBinder.getCollectionBinder(CollectionBinder.java:324)
位于org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:1723)
位于org.hibernate.cfg.AnnotationBinder.processIdPropertiesIfNotAlready(AnnotationBinder.java:796)
位于org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:707)
位于org.hibernate.cfg.Configuration$MetadataSourceQueue.processAnnotatedClassesQueue(Configuration.java:4035)
位于org.hibernate.cfg.Configuration$MetadataSourceQueue.processMetadata(Configuration.java:3989)
位于org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1398)
位于org.hibernate.cfg.Configuration.generateDropSchemaScript(Configuration.java:1002)
位于org.hibernate.tool.hbm2ddl.SchemaExport.(SchemaExport.java:130)
位于org.hibernate.tool.hbm2ddl.SchemaExport.(SchemaExport.java:92)

查看主题6.1。此服务器上的持久集合

从链接上看,,
Hibernate要求将持久集合值字段声明为接口类型。实际的接口可能是
java.util.Set、java.util.Collection、java.util.List、java.util.Map、java.util.SortedSet、java.util.SortedMap
或任何您喜欢的东西(“任何您喜欢的东西”意味着您必须编写org.hibernate.usertype.UserCollectionType的实现)。

谢谢@kalatta它帮助了我:)