very simple problem here… but I can’t work it out.
I have a simple class from my model
public class Catalogazione extends ModelEntity {
private String nome;
private int showBox;
public int getShowBox() {
return showBox;
}
public void setShowBox(int showBox) {
}
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
}
Note that ModelEntity has the an id attribute defined, integer as well.
It’s mapped on an oracle table with this mapping 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="alekso.npe.model.Catalogazione" table="Catalogazione" lazy="false">
<id name="id" column="ID">
</id>
<property name="nome" column="Nome" />
<property name="showBox" column="ShowBox" type="integer"/>
</class>
</hibernate-mapping>
Very simple.
When I retrieve the object from the DB, the showBox attribute is always 0.
This is the code for retrieving the objects list
public List<Catalogazione> getAll() throws Exception {
List<Catalogazione> catalogazioni = new ArrayList<Catalogazione>();
Session session = null;
try {
session = SessionFactoryUtil.getInstance().openSession();
String query = "from Catalogazione as cat";
catalogazioni = session.createQuery(query).list();
return catalogazioni;
} catch (Exception ex) {
// log error
} finally {
session.close();
}
}
That’s it. Every instance of Catalogazioni has showBox=0, even if in db there are several values.
Can anybody tell me why? Moreover the id is equally mapped to an integer field on the db and it works fine… what am I missing?
Your setter doesn’t do anything: