I have an Object that has a calculated field, when I try to list another object that references that object, hibernate generates an strange query, he tries to generate the code for calculating that field and this results in an wrong query. Does anybody knows what I am doing wrong? I am going to post my query code (I tried both with HQL and with Criteria API) and the mapping files.
Code:
public Lancamento[] listarLancamentos(FonteDeRecurso f) throws RepositorioLancamentosException {
Lancamento[] retorno;
List lancamentos;
try {
this.beginTransaction();
/* lancamentos = getSession().createCriteria(Lancamento.class)
.add(Expression.eq("fonteDeRecurso", f))
.list();*/
net.sf.hibernate.Query query = getSession().createQuery("select l from Lancamento as l where l.FonteDeRecurso = :fonteDeRecurso");
query.setParameter("fonteDeRecurso", f);
lancamentos = query.list();
this.commit();
retorno = (Lancamento[]) lancamentos.toArray(new Lancamento[lancamentos.size()]);
} catch (HibernateException ex) {
this.rollback();
throw new RepositorioLancamentosException("N
_________________ Rafael Ribeiro
|