Pessoal estou precisando de ajuda. Estou com problemas a tentar alterar um valor utilizando o SelectOneMenu. Alguem poderia me ajudar?
Segue código:
<h:selectOneMenu id=“perfil” value="#{ManterPerfil.perfil.id}" >
<f:selectItems value="#{ManterPerfil.listar}" />
</h:selectOneMenu>
PerfilControle
public class PerfilControle {
private Perfil perfil = new Perfil();
public List<SelectItem> getlistar() throws Exception{
PerfilDAO ad = new PerfilDAO();
List perfis = ad.listar();
ArrayList<SelectItem> listaPerfis = new ArrayList<SelectItem>();
for (int i=0; i<perfis.size(); i++) {
SelectItem perfil1 = new SelectItem();
Perfil e = (Perfil) perfis.get(i);
perfil1.setValue(e.getId());
perfil1.setLabel(e.getNome());
listaPerfis.add(perfil1);
}
return listaPerfis;
}
public Perfil getPerfil() {
return perfil;
}
public void setPerfil(Perfil perfil) {
this.perfil = perfil;
}
}
Entidade Perfil
public class Perfil implements Serializable{
private Integer id;
private String nome;
private List perfil;
public Perfil(){
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
public List getPerfil() {
return perfil;
}
public void setPerfil(List perfil) {
this.perfil = perfil;
}
}
>
Erro Ocorrido
javax.servlet.ServletException: #{ManterUsuario.alterar}: javax.faces.el.EvaluationException: org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
javax.faces.webapp.FacesServlet.service(FacesServlet.java:209)
root cause
javax.faces.FacesException: #{ManterUsuario.alterar}: javax.faces.el.EvaluationException: org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:78)
javax.faces.component.UICommand.broadcast(UICommand.java:312)
javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:267)
javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:381)
com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:75)
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:90)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)
root cause
javax.faces.el.EvaluationException: org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
com.sun.faces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:130)
com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:72)
javax.faces.component.UICommand.broadcast(UICommand.java:312)
javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:267)
javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:381)
com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:75)
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:90)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)
root cause
org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:71)
org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:202)
org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:235)
org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:140)
org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:297)
org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
org.hibernate.impl.SessionImpl.flush(SessionImpl.java:985)
dao.UsuarioDAO.alterar(UsuarioDAO.java:44)
controle.UsuarioControle.alterar(UsuarioControle.java:61)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:585)
com.sun.faces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:126)
com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:72)
javax.faces.component.UICommand.broadcast(UICommand.java:312)
javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:267)
javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:381)
com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:75)
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:90)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)
root cause
java.sql.BatchUpdateException: Entrada em lote 0 update “SMFTB001_USUARIO” set “LOGIN_SMFTB001”=Luiz Antoniodsd, “FK_SMFTB002”=NULL where “PK_SMFTB001”=96 foi abortada. Chame getNextException para ver a causa.
org.postgresql.jdbc2.AbstractJdbc2Statement$BatchResultHandler.handleError(AbstractJdbc2Statement.java:2516)
org.postgresql.core.v3.QueryExecutorImpl$1.handleError(QueryExecutorImpl.java:399)
org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1314)
org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:347)
org.postgresql.jdbc2.AbstractJdbc2Statement.executeBatch(AbstractJdbc2Statement.java:2578)
org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:58)
org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:195)
org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:235)
org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:140)
org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:297)
org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
org.hibernate.impl.SessionImpl.flush(SessionImpl.java:985)
dao.UsuarioDAO.alterar(UsuarioDAO.java:44)
controle.UsuarioControle.alterar(UsuarioControle.java:61)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:585)
com.sun.faces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:126)
com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:72)
javax.faces.component.UICommand.broadcast(UICommand.java:312)
javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:267)
javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:381)
com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:75)
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:90)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)
root cause
org.postgresql.util.PSQLException: ERRO: valor nulo na coluna “FK_SMFTB002” viola a restrição não-nula
org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1531)
org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1313)
org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:347)
org.postgresql.jdbc2.AbstractJdbc2Statement.executeBatch(AbstractJdbc2Statement.java:2578)
org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:58)
org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:195)
org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:235)
org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:140)
org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:297)
org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
org.hibernate.impl.SessionImpl.flush(SessionImpl.java:985)
dao.UsuarioDAO.alterar(UsuarioDAO.java:44)
controle.UsuarioControle.alterar(UsuarioControle.java:61)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:585)
com.sun.faces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:126)
com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:72)
javax.faces.component.UICommand.broadcast(UICommand.java:312)
javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:267)
javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:381)
com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:75)
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:90)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)
note