Ehphan Ehphan - 1 year ago 82
Java Question

Java Hibernate Mapping Exception! (Could not determine type for: java.util.Map)

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

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;
@JoinTable(name = "movie_director")
@IndexColumn(name = "directorIndex")
private List<Person> directors;
@JoinTable(name = "movie_writer")
@IndexColumn(name = "writerIndex")
private List<Person> writers;
@IndexColumn(name = "roleIndex")
private List<MovieRole> movieRoles;
@JoinTable(name = "movie_genre")
@IndexColumn(name = "genreIndex")
private List<Genre> genres;

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();

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(
at org.hibernate.mapping.SimpleValue.isValid(
at org.hibernate.mapping.Property.isValid(
at org.hibernate.mapping.PersistentClass.validate(
at org.hibernate.mapping.RootClass.validate(
at org.hibernate.cfg.Configuration.validate(
at org.hibernate.cfg.Configuration.buildSessionFactory(
at main.HibernateSessionFactory.getSessionFactory(
at main.MainClass.main(

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

Answer Source

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