The question was to persist the following class using Hibernate .
Public class Album{
Private int albumid;
Private String aname;
Private Map<String,List<String>> photos;
}
I have Tried this
@Entity
public class Album {
@Id
private int albumId;
@Column(name= "Album_Name")
private String aname;
@ElementCollection
@MapKeyColumn(name= "Event_Name")
@Column(name="Values")
private Map<String, List<String>> photos;
But it is showing errors such as
Exception in thread "main" org.hibernate.MappingException: Could not determine type for: java.util.List, at table: Album_photos, for columns: [org.hibernate.mapping.Column(Values)]
at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:336)
at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:310)
at org.hibernate.mapping.Collection.validate(Collection.java:315)
at org.hibernate.mapping.IndexedCollection.validate(IndexedCollection.java:89)
at org.hibernate.cfg.Configuration.validate(Configuration.java:1362)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1849)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1928)
at com.wipro.Insert.main(Insert.java:17)
classfor photos and use hibernate mappings like@OnetoMany,this will create 2 tables.