Jump to content
Fórum Script Brasil
  • 0

Erro de Validação - SELECTONEMENU + MYSQL


blunoblaga

Question

Caros,
Estou sofrendo há dois dias tentando identificar o erro acima que acontece quando tento gravar o cadastro e seleciono alguma opção vinda do banco no selectonemenu. Consigo salvar sem erro quando simulo o selectonemenu sendo preenchido com um item inserido no próprio corpo do código (Que Não Vem Do Banco). Estou enviando abaixo algumas classes que utilizo no meu projeto. Agradeço os interessados em ajudar.

 

Erro Pagina.png

 

Segue parte do Código em XHTML e a classe Programa:


            <div class="form-group">
                <h:outputLabel value="Qual o Programa?" for="atdPrograma" styleClass="control-label col-sm-2"/>
                <div class="col-sm-5">
                    <h:selectOneMenu value="#{atendimentoController.selected.atdPrograma}">
                        <f:selectItem itemLabel="-Selecione-" itemValue=""/>
                        <f:selectItems value="#{programaController.items}" var="e" itemValue="#{e}" itemLabel="#{e.pgrNome}" />
                        
                    </h:selectOneMenu>
                </div>
            </div>

 

CLASSE PROGRAMA:

 

//CLASSE Programa
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package pacote_jangadeiro;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author vai
 */
@Entity
@Table(name = "programa")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Programa.findAll", query = "SELECT p FROM Programa p")})
public class Programa implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "pgr_id")
    private Integer pgrId;
    @Size(max = 30)
    @Column(name = "pgr_nome")
    private String pgrNome;

    public Programa() {
    }

    public Programa(Integer pgrId) {
        this.pgrId = pgrId;
    }

    public Integer getPgrId() {
        return pgrId;
    }

    public void setPgrId(Integer pgrId) {
        this.pgrId = pgrId;
    }

    public String getPgrNome() {
        return pgrNome;
    }

    public void setPgrNome(String pgrNome) {
        this.pgrNome = pgrNome;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (pgrId != null ? pgrId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Programa)) {
            return false;
        }
        Programa other = (Programa) object;
        if ((this.pgrId == null && other.pgrId != null) || (this.pgrId != null && !this.pgrId.equals(other.pgrId))) {
            return false;
        }
        return true;
    }


    @Override
   public String toString() {
       return "pacote_jangadeiro.Programa[ pgrId=" + pgrId + " ]";
    }
   
    }
    

 

 

Edited by blunoblaga
Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      152.1k
    • Total Posts
      651.9k
×
×
  • Create New...