xml - Java Hibernate - IllegalArgumentException -


i have these 2 classes - letadlo , letiste (plane , (home)airport). while saving data db, using java , hibernate , i'm getting exception:

    16285 [thread-2] error org.hibernate.property.basicpropertyaccessor - illegalargumentexception in class: mapy.letiste, getter method of property: id org.hibernate.propertyaccessexception: illegalargumentexception occurred calling getter of mapy.letiste.id     @ org.hibernate.property.basicpropertyaccessor$basicgetter.get(basicpropertyaccessor.java:198)     @ org.hibernate.tuple.entity.abstractentitytuplizer.getidentifier(abstractentitytuplizer.java:227)     @ org.hibernate.persister.entity.abstractentitypersister.getidentifier(abstractentitypersister.java:3876)     @ org.hibernate.persister.entity.abstractentitypersister.istransient(abstractentitypersister.java:3584)     @ org.hibernate.engine.foreignkeys.istransient(foreignkeys.java:203)     @ org.hibernate.engine.foreignkeys$nullifier.isnullifiable(foreignkeys.java:159)     @ org.hibernate.engine.foreignkeys$nullifier.nullifytransientreferences(foreignkeys.java:91)     @ org.hibernate.engine.foreignkeys$nullifier.nullifytransientreferences(foreignkeys.java:69)     @ org.hibernate.event.def.abstractsaveeventlistener.performsaveorreplicate(abstractsaveeventlistener.java:310)     @ org.hibernate.event.def.abstractsaveeventlistener.performsave(abstractsaveeventlistener.java:203)     @ org.hibernate.event.def.abstractsaveeventlistener.savewithgeneratedid(abstractsaveeventlistener.java:129)     @ org.hibernate.event.def.defaultsaveorupdateeventlistener.savewithgeneratedorrequestedid(defaultsaveorupdateeventlistener.java:210)     @ org.hibernate.event.def.defaultsaveorupdateeventlistener.entityistransient(defaultsaveorupdateeventlistener.java:195)     @ org.hibernate.event.def.defaultsaveorupdateeventlistener.performsaveorupdate(defaultsaveorupdateeventlistener.java:117)     @ org.hibernate.event.def.defaultsaveorupdateeventlistener.onsaveorupdate(defaultsaveorupdateeventlistener.java:93)     @ org.hibernate.impl.sessionimpl.firesaveorupdate(sessionimpl.java:685)     @ org.hibernate.impl.sessionimpl.saveorupdate(sessionimpl.java:677)     @ org.hibernate.impl.sessionimpl.saveorupdate(sessionimpl.java:673)     @ logika.ukladanidodtb.run(ukladanidodtb.java:34)     @ java.lang.thread.run(thread.java:744) caused by: java.lang.illegalargumentexception: object not instance of declaring class     @ sun.reflect.nativemethodaccessorimpl.invoke0(native method)     @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:57)     @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43)     @ java.lang.reflect.method.invoke(method.java:606)     @ org.hibernate.property.basicpropertyaccessor$basicgetter.get(basicpropertyaccessor.java:172)     ... 19 more 

saving part:

        hibernatefactory.buildsessionfactory();         session session = hibernatefactory.opensession();          session.begintransaction().begin();          for(object o: docasneuloziste.objektykesmazani){             session.delete(o);         }          (linka l : docasneuloziste.linky) {             session.saveorupdate(l);         }         (letadlo l : docasneuloziste.letadla) {  //this 34 line             session.saveorupdate(l);         }         (letiste d : docasneuloziste.seznamletist) {              session.saveorupdate(d);         }           session.gettransaction().commit();         session.close(); 

xml of letadlo:

 <class  name="mapy.letiste">     <meta attribute="class-description">tato trida obsahuje info o domovskem letisti</meta>      <id name="id" type="long" column="letiste_id">         <generator class="native" />     </id>      <property name="kodletiste" type="string" not-null="true" length="3" column="kod_letiste"/>     <property name="mesto" type="string" not-null="true" length="35" column="mesto" />      <set name="obsluhaletadel" cascade="all">         <key column="letiste_id" />         <one-to-many class="mapy.letadlo" />     </set>  </class> 

xml of letiste:

<class  name="mapy.letiste">         <meta attribute="class-description">tato trida obsahuje info o domovskem letisti</meta>          <id name="id" type="long" column="letiste_id">             <generator class="native" />         </id>          <property name="kodletiste" type="string" not-null="true" length="3" column="kod_letiste"/>         <property name="mesto" type="string" not-null="true" length="35" column="mesto" />        <set name="obsluhaletadel" cascade="all">             <key column="letiste_id" />              <one-to-many class="mapy.letadlo" />        </set>          </class> 

class of letadlo contains variables getter , setters had in xml , constructor no parameter.

thanks suggestion!

edit: letiste class

public class letiste {     private long id;     private string kodletiste;     private string mesto;     private set<letadlo> obsluhaletadel = new hashset<letadlo>();   public letiste() { }  public letiste(string kodletiste, string mesto) { this.kodletiste = kodletiste; this.mesto = mesto; }   public string getkodletiste() {     return kodletiste; }   public void setkodletiste(string kodletiste) {     this.kodletiste = kodletiste; }  public string getmesto() {     return mesto; }   public void setmesto(string mesto) {     this.mesto = mesto; }  @override public boolean equals(object obj) {     if (obj == null) {         return false;     }     if (getclass() != obj.getclass()) {         return false;     }     final letiste other = (letiste) obj;     if ((this.kodletiste == null) ? (other.kodletiste != null) : !this.kodletiste.equals(other.kodletiste)) {         return false;     }     if ((this.mesto == null) ? (other.mesto != null) : !this.mesto.equals(other.mesto)) {         return false;     }     return true; }  @override public int hashcode() {     int hash = 7;     hash = 13 * hash + (this.kodletiste != null ? this.kodletiste.hashcode() : 0);     hash = 13 * hash + (this.mesto != null ? this.mesto.hashcode() : 0);     return hash; }   public long getid() {     return id; }  public void setid(long id) {     this.id = id; }  public set<letadlo> getobsluhaletadel() {     return obsluhaletadel; }  public void setobsluhaletadel(set<letadlo> obsluhaletadel) {     this.obsluhaletadel = obsluhaletadel; } 

edit: letadlo class

public class letadlo {     private long id;     private string kodletadla;     private string kapacita;     private integer dolet;     private set<linka> seznamlinek = new hashset<linka>();     private string letiste;      public letadlo() {     }      public letadlo(string kodletadla, string kapacita , integer dolet, string letiste) {     this.kodletadla = kodletadla;     this.kapacita = kapacita;     this.dolet = dolet;     this.letiste = letiste;     }      /**      * @return kodletadla      */     public string getkodletadla() {         return kodletadla;     }      /**      * @param kodletadla kodletadla set      */     public void setkodletadla(string kodletadla) {         this.kodletadla = kodletadla;     }      /**      * @return kapacita      */     public string getkapacita() {         return kapacita;     }      /**      * @param kapacita kapacita set      */     public void setkapacita(string kapacita) {         this.kapacita = kapacita;     }      /**      * @return dolet      */     public integer getdolet() {         return dolet;     }      /**      * @param dolet dolet set      */     public void setdolet(integer dolet) {         this.dolet = dolet;     }      @override     public boolean equals(object obj) {         if (obj == null) {             return false;         }         if (getclass() != obj.getclass()) {             return false;         }         final letadlo other = (letadlo) obj;         if (this.kodletadla != other.kodletadla && (this.kodletadla == null || !this.kodletadla.equals(other.kodletadla))) {             return false;         }         return true;     }      @override     public int hashcode() {         int hash = 7;         hash = 79 * hash + (this.kodletadla != null ? this.kodletadla.hashcode() : 0);         hash = 79 * hash + (this.kapacita != null ? this.kapacita.hashcode() : 0);         hash = 79 * hash + (this.dolet != null ? this.dolet.hashcode() : 0);         return hash;     }      /**      * @return id      */     public long getid() {         return id;     }      /**      * @param id id set      */     public void setid(long id) {         this.id = id;     }      /**      * @return seznamlinek      */     public set<linka> getseznamlinek() {         return seznamlinek;     }      /**      * @param seznamlinek seznamlinek set      */     public void setseznamlinek(set<linka> seznamlinek) {         this.seznamlinek = seznamlinek;     }      /**      * @return letiste      */     public string getletiste() {         return letiste;     }      /**      * @param letiste letiste set      */     public void setletiste(string letiste) {         this.letiste = letiste;     } 


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -