Problemas em obter dados da tabela

3 respostas
V

Pessoal, boa tarde.
Estou usando uma aplicação desenvolvida no NetBeans 5.5, TomCat 5.5.17 e estou utilizando Hibernate com os padrões JPA. Comecei a trabalhar realmente com Java semana passada e estou com essa dificuldade no momento.

aqui está a minha classe que está gerando o erro:

package br.com.projectus.proposta.dados;

import java.io.Serializable;

import java.util.Date;

import javax.persistence.Column;

import javax.persistence.Entity;

import javax.persistence.GeneratedValue;

import javax.persistence.GenerationType;

import <a href="http://javax.persistence.Id">javax.persistence.Id</a>;

import javax.persistence.Lob;

import javax.persistence.Table;

import javax.persistence.Temporal;

import javax.persistence.TemporalType;

/**

  • Entity class ProCadastro

  • @author vro1
    
    */
    
    @Entity
    
    @Table(name = pro_cadastro)
    
    public class ProCadastro implements Serializable {
    
    @Id
    
    @GeneratedValue(strategy=GenerationType.AUTO)
    
    @Column(name = codigo, nullable = false)
    
    private Integer codigo;
    

    @Column(name = “nsg”)
    private Integer nsg;

    @Column(name = “np”)
    private String np;

    @Column(name = “cliente”)
    private String cliente;

    @Column(name = data_aq)
    
    @Temporal(TemporalType.DATE)
    
    private Date dataAq;
    
    @Column(name = data_ent)
    
    @Temporal(TemporalType.DATE)
    
    private Date dataEnt;
    
    <a class="mention" href="/u/lob">@Lob</a>
    
    @Column(name = “titulo”)
    
    private String titulo;
    

    @Column(name = “coordenador”)
    private String coordenador;

    @Column(name = “n_edt”)
    private String nEdt;

    @Column(name = “ger_resp”)
    private String gerResp;

    @Column(name = “atividade”)
    private Integer atividade;

    @Column(name = “assunto”)
    private Integer assunto;

    @Column(name = “tc”)
    private String tc;

    @Column(name = “custo_edt”)
    private Double custoEdt;

    @Column(name = “vproposta”)
    private Double vproposta;

    @Column(name = “tipo”)
    private String tipo;

    @Column(name = “posicao”)
    private String posicao;

    @Column(name = “colocacao”)
    private String colocacao;

    @Column(name = “sit_arq”)
    private String sitArq;

    @Column(name = “arquivado”)
    private String arquivado;

    @Column(name = “obs”)
    private String obs;

    @Column(name = “criado”)
    private String criado;

    @Column(name = “modificado”)
    private String modificado;

    @Column(name = “subcliente”)
    private String subcliente;

    @Column(name = prorrogada)
    
    @Temporal(TemporalType.DATE)
    
    private Date prorrogada;
    

    @Column(name = “consorcio”)
    private String consorcio;

    @Column(name = “fonte”)
    private String fonte;

    /** Creates a new instance of ProCadastro */
    
    public ProCadastro() {
    
    }
    

    /**

    • Creates a new instance of ProCadastro with the specified values.
    • @param codigo the codigo of the ProCadastro
      */
      public ProCadastro(Integer codigo) {
      this.codigo = codigo;
      }

    /**

    • Gets the codigo of this ProCadastro.
    • @return the codigo
      */
      public Integer getCodigo() {
      return this.codigo;
      }

    /**

    • Sets the codigo of this ProCadastro to the specified value.
    • @param codigo the new codigo
      */
      public void setCodigo(Integer codigo) {
      this.codigo = codigo;
      }

    /**

    • Gets the nsg of this ProCadastro.
    • @return the nsg
      */
      public Integer getNsg() {
      return this.nsg;
      }

    /**

    • Sets the nsg of this ProCadastro to the specified value.
    • @param nsg the new nsg
      */
      public void setNsg(Integer nsg) {
      this.nsg = nsg;
      }

    /**

    • Gets the np of this ProCadastro.
    • @return the np
      */
      public String getNp() {
      return this.np;
      }

    /**

    • Sets the np of this ProCadastro to the specified value.
    • @param np the new np
      */
      public void setNp(String np) {
      this.np = np;
      }

    /**

    • Gets the cliente of this ProCadastro.
    • @return the cliente
      */
      public String getCliente() {
      return this.cliente;
      }

    /**

    • Sets the cliente of this ProCadastro to the specified value.
    • @param cliente the new cliente
      */
      public void setCliente(String cliente) {
      this.cliente = cliente;
      }

    /**

    • Gets the dataAq of this ProCadastro.
    • @return the dataAq
      */
      public Date getDataAq() {
      return this.dataAq;
      }

    /**

    • Sets the dataAq of this ProCadastro to the specified value.
    • @param dataAq the new dataAq
      */
      public void setDataAq(Date dataAq) {
      this.dataAq = dataAq;
      }

    /**

    • Gets the dataEnt of this ProCadastro.
    • @return the dataEnt
      */
      public Date getDataEnt() {
      return this.dataEnt;
      }

    /**

    • Sets the dataEnt of this ProCadastro to the specified value.
    • @param dataEnt the new dataEnt
      */
      public void setDataEnt(Date dataEnt) {
      this.dataEnt = dataEnt;
      }

    /**

    • Gets the titulo of this ProCadastro.
    • @return the titulo
      */
      public String getTitulo() {
      return this.titulo;
      }

    /**

    • Sets the titulo of this ProCadastro to the specified value.
    • @param titulo the new titulo
      */
      public void setTitulo(String titulo) {
      this.titulo = titulo;
      }

    /**

    • Gets the coordenador of this ProCadastro.
    • @return the coordenador
      */
      public String getCoordenador() {
      return this.coordenador;
      }

    /**

    • Sets the coordenador of this ProCadastro to the specified value.
    • @param coordenador the new coordenador
      */
      public void setCoordenador(String coordenador) {
      this.coordenador = coordenador;
      }

    /**

    • Gets the nEdt of this ProCadastro.
    • @return the nEdt
      */
      public String getNEdt() {
      return this.nEdt;
      }

    /**

    • Sets the nEdt of this ProCadastro to the specified value.
    • @param nEdt the new nEdt
      */
      public void setNEdt(String nEdt) {
      this.nEdt = nEdt;
      }

    /**

    • Gets the gerResp of this ProCadastro.
    • @return the gerResp
      */
      public String getGerResp() {
      return this.gerResp;
      }

    /**

    • Sets the gerResp of this ProCadastro to the specified value.
    • @param gerResp the new gerResp
      */
      public void setGerResp(String gerResp) {
      this.gerResp = gerResp;
      }

    /**

    • Gets the atividade of this ProCadastro.
    • @return the atividade
      */
      public Integer getAtividade() {
      return this.atividade;
      }

    /**

    • Sets the atividade of this ProCadastro to the specified value.
    • @param atividade the new atividade
      */
      public void setAtividade(Integer atividade) {
      this.atividade = atividade;
      }

    /**

    • Gets the assunto of this ProCadastro.
    • @return the assunto
      */
      public Integer getAssunto() {
      return this.assunto;
      }

    /**

    • Sets the assunto of this ProCadastro to the specified value.
    • @param assunto the new assunto
      */
      public void setAssunto(Integer assunto) {
      this.assunto = assunto;
      }

    /**

    • Gets the tc of this ProCadastro.
    • @return the tc
      */
      public String getTc() {
      return this.tc;
      }

    /**

    • Sets the tc of this ProCadastro to the specified value.
    • @param tc the new tc
      */
      public void setTc(String tc) {
      this.tc = tc;
      }

    /**

    • Gets the custoEdt of this ProCadastro.
    • @return the custoEdt
      */
      public Double getCustoEdt() {
      return this.custoEdt;
      }

    /**

    • Sets the custoEdt of this ProCadastro to the specified value.
    • @param custoEdt the new custoEdt
      */
      public void setCustoEdt(Double custoEdt) {
      this.custoEdt = custoEdt;
      }

    /**

    • Gets the vproposta of this ProCadastro.
    • @return the vproposta
      */
      public Double getVproposta() {
      return this.vproposta;
      }

    /**

    • Sets the vproposta of this ProCadastro to the specified value.
    • @param vproposta the new vproposta
      */
      public void setVproposta(Double vproposta) {
      this.vproposta = vproposta;
      }

    /**

    • Gets the tipo of this ProCadastro.
    • @return the tipo
      */
      public String getTipo() {
      return this.tipo;
      }

    /**

    • Sets the tipo of this ProCadastro to the specified value.
    • @param tipo the new tipo
      */
      public void setTipo(String tipo) {
      this.tipo = tipo;
      }

    /**

    • Gets the posicao of this ProCadastro.
    • @return the posicao
      */
      public String getPosicao() {
      return this.posicao;
      }

    /**

    • Sets the posicao of this ProCadastro to the specified value.
    • @param posicao the new posicao
      */
      public void setPosicao(String posicao) {
      this.posicao = posicao;
      }

    /**

    • Gets the colocacao of this ProCadastro.
    • @return the colocacao
      */
      public String getColocacao() {
      return this.colocacao;
      }

    /**

    • Sets the colocacao of this ProCadastro to the specified value.
    • @param colocacao the new colocacao
      */
      public void setColocacao(String colocacao) {
      this.colocacao = colocacao;
      }

    /**

    • Gets the sitArq of this ProCadastro.
    • @return the sitArq
      */
      public String getSitArq() {
      return this.sitArq;
      }

    /**

    • Sets the sitArq of this ProCadastro to the specified value.
    • @param sitArq the new sitArq
      */
      public void setSitArq(String sitArq) {
      this.sitArq = sitArq;
      }

    /**

    • Gets the arquivado of this ProCadastro.
    • @return the arquivado
      */
      public String getArquivado() {
      return this.arquivado;
      }

    /**

    • Sets the arquivado of this ProCadastro to the specified value.
    • @param arquivado the new arquivado
      */
      public void setArquivado(String arquivado) {
      this.arquivado = arquivado;
      }

    /**

    • Gets the obs of this ProCadastro.
    • @return the obs
      */
      public String getObs() {
      return this.obs;
      }

    /**

    • Sets the obs of this ProCadastro to the specified value.
    • @param obs the new obs
      */
      public void setObs(String obs) {
      this.obs = obs;
      }

    /**

    • Gets the criado of this ProCadastro.
    • @return the criado
      */
      public String getCriado() {
      return this.criado;
      }

    /**

    • Sets the criado of this ProCadastro to the specified value.
    • @param criado the new criado
      */
      public void setCriado(String criado) {
      this.criado = criado;
      }

    /**

    • Gets the modificado of this ProCadastro.
    • @return the modificado
      */
      public String getModificado() {
      return this.modificado;
      }

    /**

    • Sets the modificado of this ProCadastro to the specified value.
    • @param modificado the new modificado
      */
      public void setModificado(String modificado) {
      this.modificado = modificado;
      }

    /**

    • Gets the subcliente of this ProCadastro.
    • @return the subcliente
      */
      public String getSubcliente() {
      return this.subcliente;
      }

    /**

    • Sets the subcliente of this ProCadastro to the specified value.
    • @param subcliente the new subcliente
      */
      public void setSubcliente(String subcliente) {
      this.subcliente = subcliente;
      }

    /**

    • Gets the prorrogada of this ProCadastro.
    • @return the prorrogada
      */
      public Date getProrrogada() {
      return this.prorrogada;
      }

    /**

    • Sets the prorrogada of this ProCadastro to the specified value.
    • @param prorrogada the new prorrogada
      */
      public void setProrrogada(Date prorrogada) {
      this.prorrogada = prorrogada;
      }

    /**

    • Gets the consorcio of this ProCadastro.
    • @return the consorcio
      */
      public String getConsorcio() {
      return this.consorcio;
      }

    /**

    • Sets the consorcio of this ProCadastro to the specified value.
    • @param consorcio the new consorcio
      */
      public void setConsorcio(String consorcio) {
      this.consorcio = consorcio;
      }

    /**

    • Gets the fonte of this ProCadastro.
    • @return the fonte
      */
      public String getFonte() {
      return this.fonte;
      }

    /**

    • Sets the fonte of this ProCadastro to the specified value.
    • @param fonte the new fonte
      */
      public void setFonte(String fonte) {
      this.fonte = fonte;
      }
      }

aqui está o método que gera o erro… (não coloquei o “catch” porque senão ele iria acusar missing return statement, aí eu teria que inicializar o atributo model com null e eu não iria ver a exception na tela do tomcat, na realidade, eu não sei como acessar um log do tomcat)

public DataModel getProCadastros() {

EntityManager em = getEntityManager();

try{

Query q = em.createQuery(“select o from ProCadastro as o”);

<a href="//q.setMaxResults">//q.setMaxResults</a>(tamanhoArray);

<a href="//q.setFirstResult">//q.setFirstResult</a>(primeiroRegistro);

model = new ListDataModel(q.getResultList());

return model;

} finally {

em.close();

}

}

o persistence.xml

<?xml version="1.0" encoding="UTF-8"?> org.hibernate.ejb.HibernatePersistence br.com.projectus.proposta.dados.ProClassificacao br.com.projectus.proposta.dados.Cliente br.com.projectus.proposta.dados.ProCadastro br.com.projectus.proposta.dados.Concorrente

o faces-config.xml

<?xml version="1.0" encoding="UTF-8"?> br.com.projectus.proposta.dados.Cliente br.com.projectus.proposta.persistencia.ClienteConverter br.com.projectus.proposta.dados.Concorrente br.com.projectus.proposta.persistencia.ConcorrenteConverter br.com.projectus.proposta.dados.ProCadastro br.com.projectus.proposta.persistencia.ProCadastroConverter br.com.projectus.proposta.dados.ProClassificacao br.com.projectus.proposta.persistencia.ProClassificacaoConverter cliente br.com.projectus.proposta.persistencia.ClienteController session concorrente br.com.projectus.proposta.persistencia.ConcorrenteController session proCadastro br.com.projectus.proposta.persistencia.ProCadastroController session proClassificacao br.com.projectus.proposta.persistencia.ProClassificacaoController session cliente_create /cliente/New.jsp cliente_list /cliente/List.jsp cliente_edit /cliente/Edit.jsp cliente_detail /cliente/Detail.jsp concorrente_create /concorrente/New.jsp concorrente_list /concorrente/List.jsp concorrente_edit /concorrente/Edit.jsp concorrente_detail /concorrente/Detail.jsp proCadastro_create /proCadastro/New.jsp proCadastro_list /proCadastro/List.jsp proCadastro_edit /proCadastro/Edit.jsp proCadastro_detail /proCadastro/Detail.jsp proClassificacao_create /proClassificacao/New.jsp proClassificacao_list /proClassificacao/List.jsp proClassificacao_edit /proClassificacao/Edit.jsp proClassificacao_detail /proClassificacao/Detail.jsp

o jsp que recupera os dados através do método getProCadastros()
<%@page contentType=“text/html”%>
<%@page pageEncoding=“UTF-8”%>
<%@taglib uri=“http://java.sun.com/jsf/core” prefix=“f” %>
<%@taglib uri=“http://java.sun.com/jsf/html” prefix=“h” %>

Listar Propostas de Cadastros

Listando Propostas Cadastros



     
Voltar para a página inicial

agora, por fim, a exception…

HTTP Status 500 -

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: javax.servlet.jsp.JspException: javax.faces.el.EvaluationException: Error getting property proCadastros from bean of type br.com.projectus.proposta.persistencia.ProCadastroController: javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: could not execute query

org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)

org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)

org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)

org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)

javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368)

com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:322)

com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:130)

com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)

com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)

com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:117)

javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)

org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368)

root cause

javax.servlet.ServletException: javax.servlet.jsp.JspException: javax.faces.el.EvaluationException: Error getting property proCadastros from bean of type br.com.projectus.proposta.persistencia.ProCadastroController: javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: could not execute query

org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:854)

org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:791)

org.apache.jsp.proCadastro.List_jsp._jspService(List_jsp.java:112)

org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)

javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)

org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)

org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)

javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368)

com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:322)

com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:130)

com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)

com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)

com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:117)

javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)

org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368)

root cause

javax.faces.el.EvaluationException: javax.faces.el.EvaluationException: Error getting property proCadastros from bean of type br.com.projectus.proposta.persistencia.ProCadastroController: javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: could not execute query

com.sun.faces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:206)

com.sun.faces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:154)

javax.faces.component.UIData.getValue(UIData.java:527)

javax.faces.component.UIData.getDataModel(UIData.java:856)

javax.faces.component.UIData.setRowIndex(UIData.java:379)

com.sun.faces.renderkit.html_basic.TableRenderer.encodeBegin(TableRenderer.java:65)

javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:683)

javax.faces.component.UIData.encodeBegin(UIData.java:681)

javax.faces.webapp.UIComponentTag.encodeBegin(UIComponentTag.java:591)

javax.faces.webapp.UIComponentTag.doEndTag(UIComponentTag.java:543)

com.sun.faces.taglib.html_basic.DataTableTag.doEndTag(DataTableTag.java:491)

org.apache.jsp.proCadastro.List_jsp._jspx_meth_h_dataTable_0(List_jsp.java:455)

org.apache.jsp.proCadastro.List_jsp._jspx_meth_h_form_0(List_jsp.java:215)

org.apache.jsp.proCadastro.List_jsp._jspx_meth_f_view_0(List_jsp.java:142)

org.apache.jsp.proCadastro.List_jsp._jspService(List_jsp.java:99)

org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)

javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)

org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)

org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)

javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368)

com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:322)

com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:130)

com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)

com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)

com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:117)

javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)

org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368)

note The full stack trace of the root cause is available in the Apache Tomcat/5.5.17 logs.

Vale lembrar que estou usando um modelo gerado diretamente pelo NetBeans, até mesmo porque, estou aprendendo ainda e uso o código gerado pela IDE pra entender melhor o funcionamento do JPA e da EntityManager

Muito agradecido desde já…

Vitor Ribeiro de Oliveira

3 Respostas

V

Antes que eu me esqueça…
Essa é uma das três tabelas que estou mapeando…

com as outras duas… testei todas as operações de insert, update, select e delete e deu certo…
os métodos e os JSPs estão seguindo a mesma estrutura de desenvolvimento…

aguardo resposta…

V

Pessoal, boa tarde… consegui resolver o problema recriando a classe e o JSP, sei lá, deve ter dado algum problema no net beans.
Agora a classe compila, executa e acontece tudo normalmente, até a hora em que eu peço para o meu bean retornar o DataModel com os registros obtidos pelo SELECT…

aqui está o médodo que retorna o DataModel com os resultados do SELECT

//Método para obter todos as propostas do banco de dados

public DataModel getProCadastros(){

EntityManager em = getEntityManager();

try{

Query select = em.createQuery(select o FROM ProCadastro as o);

select.setMaxResults(gettamanhoArray());

select.setFirstResult(getprimeiroRegistro());

setModel(new ListDataModel(select.getResultList()));

} catch(Exception ex){

System.err.println("Exception occurred: "+ex);

} finally{

em.close();

}

return getModel();

}

aqui está o JSP, que chama este método

%@page contentType=“text/html”%>
<%@page pageEncoding=“UTF-8”%>
<%@taglib uri=“http://java.sun.com/jsf/core” prefix=“f” %>
<%@taglib uri=“http://java.sun.com/jsf/html” prefix=“h” %>

Listar Proposta Cadastro

Listando propostas



     
Voltar para a página inicial

Aqui está a exception gerada… (é a linha que aparece no output do TomCat)

Exception occurred: javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: could not execute query

Como já disse anteriormente, usei essa mesma estrutura para mapear outras classes e deu certo. Não sei se meu código está com algum erro de principiante, mas, até então, não consegui identificar nenhum erro. Será que pode ser algum problema no banco de dados?

Grato desde já,
Vitor Ribeiro de Oliveira

V

Vou reformular meu tópico, pois recebi uma dica de como deixar o tópico melhor visualizado, facilitando as respostas…

Aqui vai…

Pessoal, boa tarde… consegui resolver o problema recriando a classe e o JSP, sei lá, deve ter dado algum problema no net beans.
Agora a classe compila, executa e acontece tudo normalmente, até a hora em que eu peço para o meu bean retornar o DataModel com os registros obtidos pelo SELECT…

aqui está o médodo que retorna o DataModel com os resultados do SELECT

//Método para obter todos as propostas do banco de dados
public DataModel getProCadastros(){
EntityManager em = getEntityManager();
try{
Query select = em.createQuery("select o FROM ProCadastro as o");
select.setMaxResults(gettamanhoArray());
select.setFirstResult(getprimeiroRegistro());
setModel(new ListDataModel(select.getResultList()));
} catch(Exception ex){
System.err.println("Exception occurred: "+ex);
} finally{
em.close();
}
return getModel();
}

aqui está o JSP, que chama este método

%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Listar Proposta Cadastro</title>
</head>
<body>
<f:view>
<h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
<h1>Listando propostas</h1>
<h:form>
<h:commandLink action="#{proCadastro.createSetup}" value="Nova Proposta"/>
<br><br>
<h:outputText value="Item #{proCadastro.primeiroRegistro + 1}..#{proCadastro.ultimoRegistro} of #{proCadastro.itemCount}"/> 
<h:commandLink action="#{proCadastro.prev}" value="Anterior " rendered="#{proCadastro.primeiroRegistro >= proCadastro.tamanhoArray}"/> 
<h:commandLink action="#{proCadastro.next}" value="Próximo " rendered="#{proCadastro.ultimoRegistro + proCadastro.tamanhoArray <= proCadastro.itemCount}"/> 
<h:commandLink action="#{proCadastro.next}" value="Restando #{proCadastro.itemCount - proCadastro.lastItem}"
rendered="#{proCadastro.ultimoRegistro < proCadastro.itemCount && proCadastro.ultimoRegistro + proCadastro.tamanhoArray > proCadastro.itemCount}"/>
<h:dataTable value='#{proCadastro.proCadastros}' var='item' border="1" cellpadding="2" cellspacing="0">
<h:column>
<f:facet name="header">
<h:outputText value="Codigo"/>
</f:facet>
<h:commandLink action="#{proCadastro.detailSetup}" value="#{item.codigo}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Nsg"/>
</f:facet>
<h:outputText value="#{item.nsg}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Np"/>
</f:facet>
<h:outputText value="#{item.np}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Cliente"/>
</f:facet>
<h:outputText value="#{item.cliente}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Data Aquisição"/>
</f:facet>
<h:outputText value="#{item.dataAq}">
<f:convertDateTime type="DATE" pattern="MM/dd/yyyy" />
</h:outputText>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Data Entrega"/>
</f:facet>
<h:outputText value="#{item.dataEnt}">
<f:convertDateTime type="DATE" pattern="MM/dd/yyyy" />
</h:outputText>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Titulo"/>
</f:facet>
<h:outputText value="#{item.titulo}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Coordenador"/>
</f:facet>
<h:outputText value="#{item.coordenador}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="N° Edital"/>
</f:facet>
<h:outputText value="#{item.nEdt}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Gerente Responsável"/>
</f:facet>
<h:outputText value="#{item.gerResp}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Atividade"/>
</f:facet>
<h:outputText value="#{item.atividade}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Assunto"/>
</f:facet>
<h:outputText value="#{item.assunto}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Tc"/>
</f:facet>
<h:outputText value="#{item.tc}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Custo Edital"/>
</f:facet>
<h:outputText value="#{item.custoEdt}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Valor Proposta"/>
</f:facet>
<h:outputText value="#{item.vproposta}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Tipo"/>
</f:facet>
<h:outputText value="#{item.tipo}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Posicao"/>
</f:facet>
<h:outputText value="#{item.posicao}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Colocacao"/>
</f:facet>
<h:outputText value="#{item.colocacao}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Situação Arquivo"/>
</f:facet>
<h:outputText value="#{item.sitArq}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Arquivado"/>
</f:facet>
<h:outputText value="#{item.arquivado}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Observação"/>
</f:facet>
<h:outputText value="#{item.obs}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Criado"/>
</f:facet>
<h:outputText value="#{item.criado}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Modificado"/>
</f:facet>
<h:outputText value="#{item.modificado}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Subcliente"/>
</f:facet>
<h:outputText value="#{item.subcliente}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Prorrogada"/>
</f:facet>
<h:outputText value="#{item.prorrogada}">
<f:convertDateTime type="DATE" pattern="MM/dd/yyyy" />
</h:outputText>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Consorcio"/>
</f:facet>
<h:outputText value="#{item.consorcio}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Fonte"/>
</f:facet>
<h:outputText value="#{item.fonte}"/>
</h:column>
<h:column>
<h:commandLink value="Remover" action="#{proCadastro.destroy}">
<f:param name="codigo" value="#{item.codigo}"/>
</h:commandLink>
<h:outputText value=" "/>
<h:commandLink value="Editar" action="#{proCadastro.editSetup}">
<f:param name="codigo" value="#{item.codigo}"/>
</h:commandLink>
</h:column>
</h:dataTable>
<br>
<a href="/Proposta/index.jsp">Voltar para a página inicial</a>
</h:form>
</f:view>
</body>
</html>

Aqui está a exception gerada... (é a linha que aparece no output do TomCat)

Exception occurred: javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: could not execute query

Como já disse anteriormente, usei essa mesma estrutura para mapear outras classes e deu certo. Não sei se meu código está com algum erro de principiante, mas, até então, não consegui identificar nenhum erro. Será que pode ser algum problema no banco de dados?

Grato desde já,
Vitor Ribeiro de Oliveira

Criado 29 de fevereiro de 2008
Ultima resposta 5 de mar. de 2008
Respostas 3
Participantes 1