java - Hibernate mapping exception: Could not determine type for columns -


i want mapping between 2 classes customer , customergroup , getting error:

exception in thread "awt-eventqueue-0" org.hibernate.mappingexception: not determine type for: studyproject.customergroup, @ table: customer, columns: [org.hibernate.mapping.column(assignedto)] 

my customergroup class is: (fyi: @ beginning don't need bonuspackage type, therefore didn't annotate it)

package studyproject;   import javax.persistence.column; import javax.persistence.id;   public class customergroup { private string name; private string description; private int id; private bonuspackage bonuspackage;  public customergroup(int id,string name, string description,         bonuspackage bonuspackage) {     super();     this.id=id;     this.name = name;     this.description = description;     this.bonuspackage = bonuspackage; }  @column(name="id") public int getid() {     return id; }  public void setid(int id) {     this.id = id; }  @column(name="name") public string getname() {     return name; }  public void setname(string name) {     this.name = name; }  @column(name="description") public string getdescription() {     return description; }  public void setdescription(string description) {     this.description = description; } @transient public bonuspackage getbonuspackage() {     return bonuspackage; }  public void setbonuspackage(bonuspackage bonuspackage) {     this.bonuspackage = bonuspackage; } @transient public boolean generateservicemails() {     return false; } 

the customer class:

@entity @table(name="customer")  public class customer { private int id; private string forename; private string surname; private char gender; private date birthday; private double generatedprofitstotal; private double generatedprofitslastyear;     private customergroup assignedto;  public customer(int id, string forename, string surname, char gender,         date birthday) {     super();     this.id = id;     this.forename = forename;     this.surname = surname;     this.gender = gender;     this.birthday = birthday; }  @id public int getid() {     return id; }  public void setid(int id) {     this.id = id; }  @column(name = "forename") public string getforename() {     return forename; }  public void setforename(string forename) {     this.forename = forename; } @column(name = "surename") public string getsurname() {     return surname; }  public void setsurname(string surname) {     this.surname = surname; } @column(name = "gender") public char getgender() {     return gender; }  public void setgender(char gender) {     this.gender = gender; } @column(name = "birthday") public date getbirthday() {     return birthday; }  public void setbirthday(date birthday) {     this.birthday = birthday; } @column(name = "generatedprofitstotal") public double getgeneratedprofitstotal() {     return generatedprofitstotal; }  public void setgeneratedprofitstotal(double generatedprofitstotal) {     this.generatedprofitstotal = generatedprofitstotal; } @column(name = "generatedprofitslastyear") public double getgeneratedprofitslastyear() {     return generatedprofitslastyear; }  public void setgeneratedprofitslastyear(double generatedprofitslastyear) {     this.generatedprofitslastyear = generatedprofitslastyear; }   @onetoone(fetch = fetchtype.lazy, mappedby = "id", cascade = cascadetype.all) public customergroup getassignedto() {     return assignedto; }  public void setassignedto(customergroup assignedto) {     this.assignedto = assignedto; } 

the method commits transaction:

public string savealldataorm(){          configuration configuration = new configuration().configure();         serviceregistry serviceregistry = new standardserviceregistrybuilder().         applysettings(configuration.getproperties()).build();         sessionfactory sessionfactory = configuration.buildsessionfactory(serviceregistry);          session session = sessionfactory.opensession();         transaction transaction = session.begintransaction();           for(customer c:this.getcustomers()) {             session.persist(c);          }     transaction.commit();             session.close();          return "done";     } 

my customer.hbm.xml file

    <?xml version="1.0" encoding="utf-8"?> <!doctype hibernate-mapping public "-//hibernate/hibernate mapping dtd 3.0//en" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" > <hibernate-mapping> <class name="studyproject.customer"  table="customer">  <id name="id" type="int">  <column name="id"/>  <generator class="assigned"/>  </id>   <property name="forename" type="java.lang.string">  <column name="forename"/>  </property>    <property name="surname" type="java.lang.string">  <column name="surname"/>  </property>   <property name="gender" type="java.lang.character">  <column name="gender"/>  </property>    <property name="birthday" type="java.util.date">  <column name="birthday"/>  </property>   property name="generatedprofitstotal" type="java.lang.double">  <column name="generatedprofitstotal"/>  </property>   <property name="generatedprofitslastyear" type="java.lang.double">  <column name="generatedprofitslastyear"/>  </property>   <property name = "assignedto" type ="studyproject.customergroup">             <column name="assignedto" />   </property>     </class> </hibernate-mapping> 

i checked several faqs , other threads here @ stackoverflow, there problems annotations. tried fix in code can't accomplish.. :/

for better illustration have uml here: uml

assuming class customergroup reprsents customergroup table in database, add below mentioned annotations:

@entity @table(name="customergroup") public class customergroup 

Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -