java - Giving exception while mapping the simple value type of collection in hibernatre -
i have entity
called person
has name property string
, person petnames
has collection. when mapping hibernate
getting exception. how can resolve problem?
/* * change template, choose tools | templates * , open template in editor. */ package com.myapp.struts; import java.io.serializable; import java.util.set; import javax.persistence.collectiontable; import javax.persistence.elementcollection; import javax.persistence.entity; import javax.persistence.generatedvalue; import javax.persistence.generationtype; import javax.persistence.id; import javax.persistence.joincolumn; /** * * @author hyva */ @entity public class person implements serializable { private static final long serialversionuid = 1l; private long id; @id @generatedvalue(strategy = generationtype.auto) public long getid() { return id; } public string getname() { return name; } public void setname(string name) { this.name = name; } public void setpetname(set<string> petname) { this.petname = petname; } public void setid(long id) { this.id = id; } private string name; private set<string> petname; @elementcollection @collectiontable(name = "petname", joincolumns = @joincolumn(name = "person_id")) public set<string> getpetname() { return petname; } }
*exception:*
initial sessionfactory creation failed.org.hibernate.mappingexception: not determine type for: java.util.set, columns: [org.hibernate.mapping.column(petname)] exception in thread "main" java.lang.exceptionininitializererror @ com.myapp.struts.hibernateutil.<clinit>(hibernateutil.java:28) @ com.myapp.struts.hibernatecomplexvalue.main(hibernatecomplexvalue.java:19) caused by: org.hibernate.mappingexception: not determine type for: java.util.set, columns: [org.hibernate.mapping.column(petname)] @ org.hibernate.mapping.simplevalue.gettype(simplevalue.java:266) ajava result: 1
move @collectiontable
on annotation on getpetname
shown below:
private set<string> petname; @elementcollection @collectiontable(name = "pets", joincolumns =@joincolumn(name = "person_id")) public set<string> getpetname(){ return petname; }
Comments
Post a Comment