Java Hibernate映射异常! (无法确定以下类型:java.util.Map) [英] Java Hibernate Mapping Exception! (Could not determine type for: java.util.Map)

查看:583
本文介绍了Java Hibernate映射异常! (无法确定以下类型:java.util.Map)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用以下字段制作了一个名为Movie的类:

I have made a class with name of Movie with folowing fields:

    @Id
@GeneratedValue
private Long id;
private String name;
@ElementCollection(targetClass = String.class)
private Map<String, String> properties;
private Double rate;
private Integer votersCount;
private Date releaseDate;
private Integer runtime;
@ManyToMany
@JoinTable(name = "movie_director")
@IndexColumn(name = "directorIndex")
private List<Person> directors;
@ManyToMany
@JoinTable(name = "movie_writer")
@IndexColumn(name = "writerIndex")
private List<Person> writers;
@OneToMany
@IndexColumn(name = "roleIndex")
private List<MovieRole> movieRoles;
@ManyToMany
@JoinTable(name = "movie_genre")
@IndexColumn(name = "genreIndex")
private List<Genre> genres;

如您所见,

我使用了休眠注释,并且对象是bean. 但是当我尝试使用以下代码打开休眠会话时...

as you can see, I have used hibernate annotation and object is bean. but when I try to open my hibernate session with the following code...

session = HibernateSessionFactory.getSessionFactory().openSession();

我遇到有关无法映射Java.Util.Map类的问题. 这是异常堆栈跟踪:

I encounter a problem regarding could not map a Java.Util.Map class. Here is exception stack trace:

org.hibernate.MappingException: Could not determine type for: java.util.Map, for columns: [org.hibernate.mapping.Column(properties)]
at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:266)
at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:253)
at org.hibernate.mapping.Property.isValid(Property.java:185)
at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:410)
at org.hibernate.mapping.RootClass.validate(RootClass.java:192)
at org.hibernate.cfg.Configuration.validate(Configuration.java:1099)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1284)
at main.HibernateSessionFactory.getSessionFactory(HibernateSessionFactory.java:29)
at main.MainClass.main(MainClass.java:26)

我是新来的冬眠者,不知道到底是怎么回事... 请帮助我!

I'm new to hibernate and don't know exactly what's happening... please help me!

推荐答案

那是因为您必须使用一些jpa2实现!这个人遇到了相同的问题

that's because you have to use some jpa2 implementation! this guy had the same problem

这篇关于Java Hibernate映射异常! (无法确定以下类型:java.util.Map)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆