Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

219
Views
Error de fecha de tipo de entrada de primavera usando InitBinder

Estoy tratando de usar @InitBinder para mi columna 2 en mi tabla de postgres:

jsp

 <form:input type="date" id="start_date" name="start_date" path="startDate"/> <form:input type="date" id="expiry_date" name="expiry_date" path="expiryDate"/>

Controlador

 @InitBinder public void customizeBinding (WebDataBinder binder) { SimpleDateFormat dateFormatter = new SimpleDateFormat("MM/dd/yyyy"); dateFormatter.setLenient(false); binder.registerCustomEditor(Date.class, "startDate", new CustomDateEditor(dateFormatter, true)); binder.registerCustomEditor(Date.class, "expiryDate", new CustomDateEditor(dateFormatter, true)); } @RequestMapping(value = {"/create/add","/home/create/add"}, method = RequestMethod.POST) public String addContractHeader(@ModelAttribute("contractHeader") ContractHeader p, BindingResult bindingResult, Model model) { System.out.println("ENTER"); this.contractHeaderService.addContractHeader(p); return "redirect:/home/create"; }

Modelo

 @Column(name = "start_date") private Date startDate; @Column(name = "expiry_date") private Date expiryDate;

Error

 descriptionThe server encountered an internal error that prevented it from fulfilling this request. exception org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.hibernate.exception.ConstraintViolationException: could not execute statement root cause org.hibernate.exception.ConstraintViolationException: could not execute statement root cause org.postgresql.util.PSQLException: ERROR: null value in column "start_date" violates not-null constraint Detail: Failing row contains (5, dfgdsfsd, dsfdsf, sdfdsfsd, sdfsdfdsf, (888) 888-8888, arnold@yahoo.com, License, Draft, Gold, null, MYR, 4444.01, null, null, test).

Registro de la consola

 2017-04-26T16:32:50.125+0800|Info: Hibernate: insert into CONTRACT_HEADER (contact_email, contact_number, contact_person, contract_number, contract_package, contract_status, contract_sum, contract_type, currency_type, customer_address, customer_name, expiry_date, package_other, remarks, start_date) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) 2017-04-26T16:32:50.126+0800|WARN: SQL Error: 0, SQLState: 23502 2017-04-26T16:32:50.126+0800|ERROR: ERROR: null value in column "start_date" violates not-null constraint Detail: Failing row contains (7, qqqqq, qqqq, qqqqqqqq, qqqqqq, (888) 888-8888, arnold@yahoo.com, License, Draft, Gold, null, MYR, 4444.01, null, null, dfdfdfd).

¿Por qué está tratando de insertar nulo, nulo, en mis columnas de fecha cuando ya especifiqué 26/04/2017 y 30/04/2017 como entrada para ambos campos?

EDITAR:

Editor de fecha personalizada

 public CustomDateEditor(DateFormat dateFormat, boolean allowEmpty) { this.dateFormat = dateFormat; this.allowEmpty = allowEmpty; this.exactDateLength = -1; }
over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!