Hi There!
I'm facing problems with my web-app using hibernate.
I have a stored procedure in my database that returns me a table.
the fields are coditabe, inclaces, alteaces, consaces, exclaces
the question is... how do I do to map this one?
I have read that it's on this way:
Code:
<sql-query name="POVIACES" callable="true">
<return alias="emp" class="Poviaces">
<return-property name="id" column="CODITABE"/>
<return-property name="inclaces" column="INCLACES"/>
<return-property name="alteaces" column="ALTEACES"/>
<return-property name="consaces" column="CONSACES"/>
<return-property name="exclaces" column="EXCLACES"/>
</return>
{ ? = call POVIACES() }
</sql-query>
my class is:
Code:
public class Poviaces implements java.io.Serializable {
//campos
private long id;
private boolean inclaces;
private boolean alteaces;
private boolean consaces;
private boolean exclaces;
public Poviaces() {
}
/** minimal constructor */
public Poviaces(long coditabe) {
this.id = coditabe;
}
public void setInclaces(boolean inclaces) {
this.inclaces = inclaces;
}
public boolean isInclaces() {
return inclaces;
}
public void setAlteaces(boolean alteaces) {
this.alteaces = alteaces;
}
public boolean isAlteaces() {
return alteaces;
}
public void setConsaces(boolean consaces) {
this.consaces = consaces;
}
public boolean isConsaces() {
return consaces;
}
public void setExclaces(boolean exclaces) {
this.exclaces = exclaces;
}
public boolean isExclaces() {
return exclaces;
}
public void setId(long id) {
this.id = id;
}
public long getId() {
return id;
}
}
to obtain one object from class poviaces I call
[code Session s = (isSessionSuplied() ? getSession() : getNewSession());
try {
List list =
s.createSQLQuery("SELECT * FROM POVIACES WHERE CODITABE = " + tabe.getCoditabe() + ""). list();
if (list.size() > 0) {
return (Poviaces)list.get(0);
} else {
return null;
}
} catch (HibernateException hex) {
hex.printStackTrace();
throw hex;
} finally {
if (!isSessionSuplied()) {
s.close();
}
}
} [/code]
ok...
till then, I get one result in my list as I expected. but in the return, it returns me a null object, a null Poviaces...
why???