-
estou tentando cadastrar o paciente porém esse erro é apresentado: /usr/lib/jvm/java-11-openjdk-amd64/bin/java -Dfile.encoding=UTF-8 @/tmp/cp_5b8gbphrthz5w0l5p8vkiuae1.argfile teste.Teste mai 03, 2020 12:17:44 PM org.hibernate.jpa.internal.util.LogHelper logPersistenceUnitInformation INFO: HHH000204: Processing PersistenceUnitInfo [name: clinicaodontologica] mai 03, 2020 12:17:46 PM org.hibernate.Version logVersion INFO: HHH000412: Hibernate Core {5.4.1.Final} mai 03, 2020 12:17:49 PM org.hibernate.annotations.common.reflection.java.JavaReflectionManager INFO: HCANN000001: Hibernate Commons Annotations {5.1.0.Final} mai 03, 2020 12:17:51 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure WARN: HHH10001002: Using Hibernate built-in connection pool (not for production use!) mai 03, 2020 12:17:51 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator INFO: HHH10001005: using driver [org.postgresql.Driver] at URL [jdbc:postgresql://localhost/clinicaodontologica] mai 03, 2020 12:17:51 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator INFO: HHH10001001: Connection properties: {password=****, user=postgres, shutdown=true} mai 03, 2020 12:17:51 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator INFO: HHH10001003: Autocommit mode: false mai 03, 2020 12:17:51 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl$PooledConnections INFO: HHH000115: Hibernate connection pool size: 20 (min=1) mai 03, 2020 12:18:02 PM org.hibernate.dialect.Dialect INFO: HHH000400: Using dialect: org.hibernate.dialect.PostgreSQLDialect mai 03, 2020 12:18:13 PM org.hibernate.validator.internal.util.Version INFO: HV000001: Hibernate Validator 6.0.16.Final mai 03, 2020 12:18:14 PM org.hibernate.engine.transaction.jta.platform.internal.JtaPlatformInitiator initiateService INFO: HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform] chegou no model Hibernate: select nextval ('hibernate_sequence') Hibernate: insert into usuario (cpf, bairro, cep, cidade, complemento, estado, numero, pais, rua, formacao, email, senha, profissao, id_RG, sexo, telefone, TIPO_USUARIO, idUsuario) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 'paciente', ?) mai 03, 2020 12:18:14 PM org.hibernate.engine.jdbc.batch.internal.AbstractBatchImpl release INFO: HHH000010: On release of batch it still contained JDBC statements mai 03, 2020 12:18:14 PM org.hibernate.engine.jdbc.batch.internal.BatchingBatch performExecution ERROR: HHH000315: Exception executing batch [java.sql.BatchUpdateException: Batch entry 0 insert into usuario (cpf, bairro, cep, cidade, complemento, estado, numero, pais, rua, formacao, email, senha, profissao, id_RG, sexo, telefone, TIPO_USUARIO, idUsuario) values ('04624792069', 'Heli�polis', '55200-000', 'Garanhuns', 'Casa', 'Pernambuco', 58, 'Brasil', 'Manoel dos Santos', 'Engenharia', 'gute@gmail.com', '123', 'Engenheiro Civil', NULL, 'M', '(87) 3761-8479', 'paciente', 4) was aborted: ERROR: null value in column "cro" violates not-null constraint Detalhe: Failing row contains (paciente, 4, 04624792069, Heli�polis, 55200-000, Garanhuns, Casa, Pernambuco, 58, Brasil, Manoel dos Santos, Engenharia, gute@gmail.com, 123, Engenheiro Civil, M, (87) 3761-8479, null, null). Call getNextException to see other errors in the batch.], SQL: insert into usuario (cpf, bairro, cep, cidade, complemento, estado, numero, pais, rua, formacao, email, senha, profissao, id_RG, sexo, telefone, TIPO_USUARIO, idUsuario) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 'paciente', ?) mai 03, 2020 12:18:14 PM org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions WARN: SQL Error: 0, SQLState: 23502 mai 03, 2020 12:18:14 PM org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions ERROR: Batch entry 0 insert into usuario (cpf, bairro, cep, cidade, complemento, estado, numero, pais, rua, formacao, email, senha, profissao, id_RG, sexo, telefone, TIPO_USUARIO, idUsuario) values ('04624792069', 'Heli�polis', '55200-000', 'Garanhuns', 'Casa', 'Pernambuco', 58, 'Brasil', 'Manoel dos Santos', 'Engenharia', 'gute@gmail.com', '123', 'Engenheiro Civil', NULL, 'M', '(87) 3761-8479', 'paciente', 4) was aborted: ERROR: null value in column "cro" violates not-null constraint Detalhe: Failing row contains (paciente, 4, 04624792069, Heli�polis, 55200-000, Garanhuns, Casa, Pernambuco, 58, Brasil, Manoel dos Santos, Engenharia, gute@gmail.com, 123, Engenheiro Civil, M, (87) 3761-8479, null, null). Call getNextException to see other errors in the batch. mai 03, 2020 12:18:14 PM org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions ERROR: ERROR: null value in column "cro" violates not-null constraint Detalhe: Failing row contains (paciente, 4, 04624792069, Heli�polis, 55200-000, Garanhuns, Casa, Pernambuco, 58, Brasil, Manoel dos Santos, Engenharia, gute@gmail.com, 123, Engenheiro Civil, M, (87) 3761-8479, null, null). mai 03, 2020 12:18:14 PM org.hibernate.internal.ExceptionMapperStandardImpl mapManagedFlushFailure ERROR: HHH000346: Error during managed flush [org.hibernate.exception.ConstraintViolationException: could not execute batch] mai 03, 2020 12:18:14 PM org.hibernate.engine.internal.StatisticalLoggingSessionEventListener end INFO: Session Metrics { 80660 nanoseconds spent acquiring 1 JDBC connections; 32256 nanoseconds spent releasing 1 JDBC connections; 688041 nanoseconds spent preparing 2 JDBC statements; 18959952 nanoseconds spent executing 1 JDBC statements; 68884880 nanoseconds spent executing 1 JDBC batches; 0 nanoseconds spent performing 0 L2C puts; 0 nanoseconds spent performing 0 L2C hits; 0 nanoseconds spent performing 0 L2C misses; 97839128 nanoseconds spent executing 1 flushes (flushing a total of 1 entities and 0 collections); 0 nanoseconds spent executing 0 partial-flushes (flushing a total of 0 entities and 0 collections) } java.lang.NullPointerException at Controller.ControllerPaciente.cadastrarPaciente(ControllerPaciente.java:33) at teste.Teste.main(Teste.java:191) SEGUE O CÓDIGO(já me certifiquei que não tenha nenhum dado faltando relativo a paciente que está como nulllabel=false) package Controller; import java.util.List; import javax.faces.application.FacesMessage; import javax.faces.bean.ManagedBean; import javax.faces.bean.RequestScoped; import javax.faces.context.FacesContext; import model.PacienteModel; import model.entidades.Paciente; @ManagedBean @RequestScoped public class ControllerPaciente { private PacienteModel pacienteModel; private Paciente paciente; public ControllerPaciente() { pacienteModel = new PacienteModel(); paciente = new Paciente(); } public void cadastrarPaciente() throws Exception{ FacesContext context = FacesContext.getCurrentInstance(); try { System.out.println("chegou no model"); pacienteModel.inserirPaciente(paciente); //paciente = new Paciente(); //context.addMessage(null, new FacesMessage("Cadastro Efetuado!")); System.out.println("passou do model"); } catch (Exception e) { context.addMessage(null, new FacesMessage(e.getMessage())); } } ControllerPaciente cp = new ControllerPaciente(); /* Cadastrar Paciente */ cp.getPaciente().setCpf("04624792069"); cp.getPaciente().setFormacao("Engenharia"); cp.getPaciente().setSexo('M'); cp.getPaciente().setTelefone("(87) 3761-8479"); // colocar data de nascimento cp.getPaciente().setProfissao("Engenheiro Civil"); //cp.getPaciente().getRg().setNumero("876987123"); cp.getPaciente().getEndereco().setRua("Manoel dos Santos"); cp.getPaciente().getEndereco().setPais("Brasil"); cp.getPaciente().getEndereco().setNumero(58); cp.getPaciente().getEndereco().setEstado("Pernambuco"); cp.getPaciente().getEndereco().setComplemento("Casa"); cp.getPaciente().getEndereco().setCidade("Garanhuns"); cp.getPaciente().getEndereco().setBairro("Heli�polis"); cp.getPaciente().getEndereco().setCep("55200-000"); cp.getPaciente().getLogin().setEmail("gute@gmail.com"); cp.getPaciente().getLogin().setSenha("123"); cp.cadastrarPaciente();
dimanche 3 mai 2020
java.lang.NullPointerException at Controller.ControllerPaciente.cadastrarPaciente(ControllerPaciente.java:33) at teste.Teste.main(Teste.java:191)
Inscription à :
Publier les commentaires (Atom)
Aucun commentaire:
Enregistrer un commentaire