java - Hibernate ERROR: HHH000091 -


i new hibernate. goal query results arraylist keep getting error: hhh000091: expected type: int, actual value: org.hibernate.collection.internal.persistentset

i believe problem in mapping, appreciated.

errors

error: hhh000123: illegalargumentexception in class: com.mycompany.mavenproject1.medicamento, setter method of property: labjoin apr 07, 2017 10:23:10 org.hibernate.property.basicpropertyaccessor$basicsetter set error: hhh000091: expected type: int, actual value: org.hibernate.collection.internal.persistentset

my hql query:

from medicamento m left join laboratorio l l.codigolab=m.codigolab 

mapping xml:

<class name="com.mycompany.mavenproject1.medicamento" table="medicamento" schema="adminfarmacia" optimistic-lock="version">   <id name="codigomed" type="long">             <column name="codigo_med" not-null="true"/>             <generator class="assigned" />         </id>         <property name="nombrecomercial" type="string">             <column name="nombre_comercial" length="100" not-null="true" />         </property>         <property name="codigoprincipio" type="string">             <column name="codigo_principio" length="50" not-null="true" />         </property>         <property name="stockminimo" type="java.lang.integer">             <column name="stock_minimo" />         </property>         <property name="codigolab" type="java.lang.integer">             <column name="codigo_lab"  />         </property>         <property name="comentario" type="string">             <column name="comentario" length="1000" />         </property>         <property name="existencias" type="java.lang.integer">             <column name="existencias"/>         </property>         <set name="labjoin"  fetch="join">                       <key column="codigo_lab" />             <one-to-many class="com.mycompany.mavenproject1.laboratorio"/>         </set> </class> 

laboratorio.java:

public class laboratorio implements java.io.serializable{     private int codigolab;     private string nombrelab;      public laboratorio(){      }      public int getcodigolab() {         return codigolab;     }      public void setcodigolab(int codigolab) {         this.codigolab = codigolab;     }      public string getnombrelab() {         return nombrelab;     }      public void setnombrelab(string nombrelab) {         this.nombrelab = nombrelab;     }     } 

medicamento.java - in 1 labjoin , labname fields on "laboratorio" table

public class medicamento implements java.io.serializable{ private long codigomed; private string nombrecomercial; private string codigoprincipio; private int stockminimo; private int codigolab; private string comentario; private int existencias; private int labjoin; private string labname;  public medicamento(){  } public long getcodigomed() {     return codigomed; }  public void setcodigomed(long codigomed) {     this.codigomed = codigomed; }  public string getnombrecomercial() {     return nombrecomercial; }  public void setnombrecomercial(string nombrecomercial) {     this.nombrecomercial = nombrecomercial; }  public string getcodigoprincipio() {     return codigoprincipio; }  public void setcodigoprincipio(string codigoprincipio) {     this.codigoprincipio = codigoprincipio; }  public int getstockminimo() {     return stockminimo; }  public void setstockminimo(int stockminimo) {     this.stockminimo = stockminimo; }  public int getcodigolab() {     return codigolab; }  public void setcodigolab(int codigolab) {     this.codigolab = codigolab; }  public int getlabjoin() {     return labjoin; }  public void setlabjoin(int labjoin) {     this.labjoin = labjoin; }  public string getlabname() {     return labname; }  public void setlabjoin(string labname) {     this.labname= labname; }  public string getcomentario() {     return comentario; }  public void setcomentario(string comentario) {     this.comentario = comentario; }  public int getexistencias() {     return existencias; }  public void setexistencias(int existencias) {     this.existencias = existencias; } 

}

calling method

private void displayresult(list rl){             arraylist<object> onerow = new arraylist<object>();             (object o: rl){                 medicamento medlist = (medicamento)o;                 system.out.println(lablist.getcodigolab());                 onerow.add(medlist.getcodigomed());                 onerow.add(medlist.getexistencias());                 onerow.add(medlist.getnombrecomercial());                 onerow.add(medlist.getlabjoin());             }             lowstocktablemodel model = new lowstocktablemodel(onerow);             try{                 jtable1.setmodel(model);             }             catch (exception e){                 joptionpane.showmessagedialog(null, e.getlocalizedmessage(),"error",joptionpane.error_message);                 jtextfield1.settext("");             }         } 

in mapping, have

<set name="labjoin"  fetch="join">                   <key column="codigo_lab" />         <one-to-many class="com.mycompany.mavenproject1.laboratorio"/>     </set> 

but property labjoin has type int. type of property has set<laboratorio>.


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -