Array de Dados vindo NULL do banco

Bom dia Galera estou aqui mais uma vez pra pedir ajuda de vcs.

Seguinte tenho uma view no banco de dados com algumas funções tb feitas no banco de dados, essa view traz dados de datas calculadas.

Aqui é onde eu faço minha busca pra me retornar os valores da minha view.


public List<EtapaView> todasEtapasView(int idclasse, int idaval) {
        System.out.println("todasEtapasView");
        session = HibernateUtil.getInstance();

        String query = " SELECT epv FROM EtapaView epv, Classe c, Prova p "
                + " WHERE epv.id.idaval = p.idaval "
                + " AND epv.id.idclasse = c.idclasse "
                + " AND c.idclasse = " + idclasse
                + " AND p.idaval = " + idaval;


        System.out.println("query " + query);


        List q = session.createQuery(query).list();
        System.out.println("etapa padrao List " + q); //<------- Só que o retorno é esse "etapa padrao List [null, null, null, null, null]"

        return q;
    }

Testei essa query no banco de dados ele me retornou os dados certinhos.

Estou na dúvida pq que os arrays mostrados acima estão vindo null.

Pois na minha datatable da minha jsf eu soh quero mostrar os dados da view do banco, pois já estão calculados.

desde já agradeço

Só uma dica.
Não use concatenação de String para criar a consulta.
Além da nada performático, afinal cada vez que você concatena uma String com outra uma terceira é criada.
Use StringBuilder com o método append.

Outra coisa esquisita aí é que você está usando o hibernate não é.
No hibernate você pode referenciar os atributos por nomes.
Assim.

session = HibernateUtil.getInstance();  

StringBuilder sql = new StringBuilder();
sql.append("SELECT epv FROM EtapaView epv, Classe c, Prova p ");
sql.append("WHERE epv.id.idaval = p.idaval AND epv.id.idclasse = c.idclasse" );
sql.append(" AND c.idclasse = :idClasse" );
sql.append("AND p.idaval = :idaval ");
Query q  = session.createQuery(sql.toString());
q.setParameter("idClasse",idclasse);
q.setParameter("idaval",idaval);
List lista = q.list();

Tenta fazer assim para ver se retorna.
Só uma curiosidade.
Você está usando oracle ?

e aew lele_vader blz??

Primeiramente vlw a dica sempre é bom conversar com outras pessoas que entendem de programação. Aqui onde trabalho eu sou tudo DBA, Analista, Programador e por aí vai.

Pow entaum olhei aqui fiz o teste e o retorno foi o mesmo.
Sim estou usando Hibernate e Postgresql

Engraçado que em outra jsf eu mostro uma view toda calculada bunitinho.

Tipo assim as functions do banco podem influenciar em alguma coisa??
pois essa view EtapaView utiliza functions no banco e tem valor necessário pra mostrar pro user.


 public List todasEtapasView(int idclasse, int idaval) {
        System.out.println("todasEtapasView");
        session = HibernateUtil.getInstance();
     
        StringBuilder sql = new StringBuilder();
        sql.append(" SELECT epv FROM EtapaView epv, Classe c, Prova p ");
        sql.append(" WHERE epv.id.idaval = p.idaval AND epv.id.idclasse = c.idclasse ");
        sql.append(" AND c.idclasse = :idClasse ");
        sql.append(" AND p.idaval = :idaval ");
        Query q = session.createQuery(sql.toString());
        q.setParameter("idClasse", idclasse);
        q.setParameter("idaval", idaval);
        List lista = q.list();


        System.out.println("query " + q); // query QueryImpl( SELECT epv FROM EtapaView epv, Classe c, Prova p  WHERE epv.id.idaval = p.idaval AND epv.id.idclasse = c.idclasse  AND c.idclasse = :idClasse  AND p.idaval = :idaval )

     
        System.out.println("etapa padrao List " + lista); // etapa padrao List [null, null, null, null, null]

        return lista;
    }

Essa etapaView está mapeada em uma classe ?

Pode mostra-la ?

segue minha EtapaView.hbm.xml


<?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">
<!-- Generated 05/07/2012 11:34:23 by Hibernate Tools 3.2.1.GA -->
<hibernate-mapping>
  <class name="model.view.EtapaView" schema="public" table="c_etapa">
    <composite-id class="model.view.EtapaViewId" name="id">
      <key-property name="etapa" type="string">
        <column length="100" name="etapa"/>
      </key-property>
      <key-property name="idaval" type="java.lang.Integer">
        <column name="idaval"/>
      </key-property>
      <key-property name="idclasse" type="java.lang.Integer">
        <column name="idclasse"/>
      </key-property>
      <key-property name="idetapa" type="java.lang.Integer">
        <column name="idetapa"/>
      </key-property>
      <key-property name="dtinicio" type="timestamp">
        <column length="29" name="dtinicio"/>
      </key-property>
      <key-property name="dtfim" type="timestamp">
        <column length="29" name="dtfim"/>
      </key-property>
      <key-property name="dtinicioprevisao" type="timestamp">
        <column length="29" name="dtinicioprevisao"/>
      </key-property>
      <key-property name="obs" type="string">
        <column name="obs"/>
      </key-property>
      <key-property name="feriadoprevisao" type="java.lang.Short">
        <column name="feriadoprevisao"/>
      </key-property>
      <key-property name="feriadoefetivo" type="java.lang.Short">
        <column name="feriadoefetivo"/>
      </key-property>
      <key-property name="duracaoprevista" type="java.lang.Float">
        <column name="duracaoprevista" precision="8" scale="8"/>
      </key-property>
      <key-property name="retardo" type="java.lang.Short">
        <column name="retardo"/>
      </key-property>
      <key-property name="duracaoefetiva" type="java.lang.Double">
        <column name="duracaoefetiva" precision="17" scale="17"/>
      </key-property>
      <key-property name="terminoprevisto" type="date">
        <column length="13" name="terminoprevisto"/>
      </key-property>
    </composite-id>
  </class>
</hibernate-mapping>


minha EtapaViewId.java

[code]package model.view;
// Generated 05/07/2012 11:34:19 by Hibernate Tools 3.2.1.GA

import java.util.Date;

/**

  • CEtapaId generated by hbm2java
    */
    public class EtapaViewId implements java.io.Serializable {

    private String etapa;
    private Integer idaval;
    private Integer idclasse;
    private Integer idetapa;
    private Date dtinicio;
    private Date dtfim;
    private Date dtinicioprevisao;
    private String obs;
    private Short feriadoprevisao;
    private Short feriadoefetivo;
    private Float duracaoprevista;
    private Short retardo;
    private Double duracaoefetiva;
    private Date terminoprevisto;

    public EtapaViewId() {
    }

    public EtapaViewId(String etapa, Integer idaval, Integer idclasse, Integer idetapa, Date dtinicio, Date dtfim,
    Date dtinicioprevisao, String obs, Short feriadoprevisao, Short feriadoefetivo, Float duracaoprevista, Short retardo,
    Double duracaoefetiva, Date terminoprevisto) {
    this.etapa = etapa;
    this.idaval = idaval;
    this.idclasse = idclasse;
    this.idetapa = idetapa;
    this.dtinicio = dtinicio;
    this.dtfim = dtfim;
    this.dtinicioprevisao = dtinicioprevisao;
    this.obs = obs;
    this.feriadoprevisao = feriadoprevisao;
    this.feriadoefetivo = feriadoefetivo;
    this.duracaoprevista = duracaoprevista;
    this.retardo = retardo;
    this.duracaoefetiva = duracaoefetiva;
    this.terminoprevisto = terminoprevisto;
    }

    public String getEtapa() {
    return this.etapa;
    }

    public void setEtapa(String etapa) {
    this.etapa = etapa;
    }
    public Integer getIdaval() {
    return this.idaval;
    }

    public void setIdaval(Integer idaval) {
    this.idaval = idaval;
    }
    public Integer getIdclasse() {
    return this.idclasse;
    }

    public void setIdclasse(Integer idclasse) {
    this.idclasse = idclasse;
    }
    public Integer getIdetapa() {
    return this.idetapa;
    }

    public void setIdetapa(Integer idetapa) {
    this.idetapa = idetapa;
    }
    public Date getDtinicio() {
    return this.dtinicio;
    }

    public void setDtinicio(Date dtinicio) {
    this.dtinicio = dtinicio;
    }
    public Date getDtfim() {
    return this.dtfim;
    }

    public void setDtfim(Date dtfim) {
    this.dtfim = dtfim;
    }
    public Date getDtinicioprevisao() {
    return this.dtinicioprevisao;
    }

    public void setDtinicioprevisao(Date dtinicioprevisao) {
    this.dtinicioprevisao = dtinicioprevisao;
    }
    public String getObs() {
    return this.obs;
    }

    public void setObs(String obs) {
    this.obs = obs;
    }
    public Short getFeriadoprevisao() {
    return this.feriadoprevisao;
    }

    public void setFeriadoprevisao(Short feriadoprevisao) {
    this.feriadoprevisao = feriadoprevisao;
    }
    public Short getFeriadoefetivo() {
    return this.feriadoefetivo;
    }

    public void setFeriadoefetivo(Short feriadoefetivo) {
    this.feriadoefetivo = feriadoefetivo;
    }
    public Float getDuracaoprevista() {
    return this.duracaoprevista;
    }

    public void setDuracaoprevista(Float duracaoprevista) {
    this.duracaoprevista = duracaoprevista;
    }
    public Short getRetardo() {
    return this.retardo;
    }

    public void setRetardo(Short retardo) {
    this.retardo = retardo;
    }
    public Double getDuracaoefetiva() {
    return this.duracaoefetiva;
    }

    public void setDuracaoefetiva(Double duracaoefetiva) {
    this.duracaoefetiva = duracaoefetiva;
    }
    public Date getTerminoprevisto() {
    return this.terminoprevisto;
    }

    public void setTerminoprevisto(Date terminoprevisto) {
    this.terminoprevisto = terminoprevisto;
    }

    public boolean equals(Object other) {
    if ( (this == other ) ) return true;
    if ( (other == null ) ) return false;
    if ( !(other instanceof EtapaViewId) ) return false;
    EtapaViewId castOther = ( EtapaViewId ) other;

      return ( (this.getEtapa()==castOther.getEtapa()) || ( this.getEtapa()!=null && castOther.getEtapa()!=null && this.getEtapa().equals(castOther.getEtapa()) ) )
    

&& ( (this.getIdaval()==castOther.getIdaval()) || ( this.getIdaval()!=null && castOther.getIdaval()!=null && this.getIdaval().equals(castOther.getIdaval()) ) )
&& ( (this.getIdclasse()==castOther.getIdclasse()) || ( this.getIdclasse()!=null && castOther.getIdclasse()!=null && this.getIdclasse().equals(castOther.getIdclasse()) ) )
&& ( (this.getIdetapa()==castOther.getIdetapa()) || ( this.getIdetapa()!=null && castOther.getIdetapa()!=null && this.getIdetapa().equals(castOther.getIdetapa()) ) )
&& ( (this.getDtinicio()==castOther.getDtinicio()) || ( this.getDtinicio()!=null && castOther.getDtinicio()!=null && this.getDtinicio().equals(castOther.getDtinicio()) ) )
&& ( (this.getDtfim()==castOther.getDtfim()) || ( this.getDtfim()!=null && castOther.getDtfim()!=null && this.getDtfim().equals(castOther.getDtfim()) ) )
&& ( (this.getDtinicioprevisao()==castOther.getDtinicioprevisao()) || ( this.getDtinicioprevisao()!=null && castOther.getDtinicioprevisao()!=null && this.getDtinicioprevisao().equals(castOther.getDtinicioprevisao()) ) )
&& ( (this.getObs()==castOther.getObs()) || ( this.getObs()!=null && castOther.getObs()!=null && this.getObs().equals(castOther.getObs()) ) )
&& ( (this.getFeriadoprevisao()==castOther.getFeriadoprevisao()) || ( this.getFeriadoprevisao()!=null && castOther.getFeriadoprevisao()!=null && this.getFeriadoprevisao().equals(castOther.getFeriadoprevisao()) ) )
&& ( (this.getFeriadoefetivo()==castOther.getFeriadoefetivo()) || ( this.getFeriadoefetivo()!=null && castOther.getFeriadoefetivo()!=null && this.getFeriadoefetivo().equals(castOther.getFeriadoefetivo()) ) )
&& ( (this.getDuracaoprevista()==castOther.getDuracaoprevista()) || ( this.getDuracaoprevista()!=null && castOther.getDuracaoprevista()!=null && this.getDuracaoprevista().equals(castOther.getDuracaoprevista()) ) )
&& ( (this.getRetardo()==castOther.getRetardo()) || ( this.getRetardo()!=null && castOther.getRetardo()!=null && this.getRetardo().equals(castOther.getRetardo()) ) )
&& ( (this.getDuracaoefetiva()==castOther.getDuracaoefetiva()) || ( this.getDuracaoefetiva()!=null && castOther.getDuracaoefetiva()!=null && this.getDuracaoefetiva().equals(castOther.getDuracaoefetiva()) ) )
&& ( (this.getTerminoprevisto()==castOther.getTerminoprevisto()) || ( this.getTerminoprevisto()!=null && castOther.getTerminoprevisto()!=null && this.getTerminoprevisto().equals(castOther.getTerminoprevisto()) ) );
}

public int hashCode() {
int result = 17;

     result = 37 * result + ( getEtapa() == null ? 0 : this.getEtapa().hashCode() );
     result = 37 * result + ( getIdaval() == null ? 0 : this.getIdaval().hashCode() );
     result = 37 * result + ( getIdclasse() == null ? 0 : this.getIdclasse().hashCode() );
     result = 37 * result + ( getIdetapa() == null ? 0 : this.getIdetapa().hashCode() );
     result = 37 * result + ( getDtinicio() == null ? 0 : this.getDtinicio().hashCode() );
     result = 37 * result + ( getDtfim() == null ? 0 : this.getDtfim().hashCode() );
     result = 37 * result + ( getDtinicioprevisao() == null ? 0 : this.getDtinicioprevisao().hashCode() );
     result = 37 * result + ( getObs() == null ? 0 : this.getObs().hashCode() );
     result = 37 * result + ( getFeriadoprevisao() == null ? 0 : this.getFeriadoprevisao().hashCode() );
     result = 37 * result + ( getFeriadoefetivo() == null ? 0 : this.getFeriadoefetivo().hashCode() );
     result = 37 * result + ( getDuracaoprevista() == null ? 0 : this.getDuracaoprevista().hashCode() );
     result = 37 * result + ( getRetardo() == null ? 0 : this.getRetardo().hashCode() );
     result = 37 * result + ( getDuracaoefetiva() == null ? 0 : this.getDuracaoefetiva().hashCode() );
     result = 37 * result + ( getTerminoprevisto() == null ? 0 : this.getTerminoprevisto().hashCode() );
     return result;

}

}

[/code]

e minha EtapaView.java

package model.view;
// Generated 05/07/2012 11:34:19 by Hibernate Tools 3.2.1.GA



/**
 * CEtapa generated by hbm2java
 */
public class EtapaView  implements java.io.Serializable {


     private EtapaViewId id;

    public EtapaView() {
    }

    public EtapaView(EtapaViewId id) {
       this.id = id;
    }
   
    public EtapaViewId getId() {
        return this.id;
    }
    
    public void setId(EtapaViewId id) {
        this.id = id;
    }




}

e ela está mapeada sim no hibernate.cfg.xml

 <mapping resource="model/view/EtapaView.hbm.xml"/>

minha dúvida tah sumindo da lista na primeira página alguem sabe dizer pq???

A consulta com os mesmos parâmetros tem valor ?

o valor da minha lista eh tudo null

[null, null, null, null, null] <<---- esses são os arrays da minha consulta.