【问题标题】:Error - Could not commit JPA transaction; nested exception is javax.persistence.RollbackException错误 - 无法提交 JPA 事务;嵌套异常是 javax.persistence.RollbackException
【发布时间】:2021-09-02 06:52:21
【问题描述】:

我在尝试添加新员工时遇到此错误。无法提交 JPA 事务;嵌套异常是 javax.persistence.RollbackException: Error while committing the transaction 提交事务时出错] 的根本原因 java.lang.UnsupportedOperationException: null

   @RequestMapping(
        method = RequestMethod.POST,
        value = "addEmployeeDetails",
        produces = MediaType.APPLICATION_JSON_VALUE,
        consumes = (MediaType.APPLICATION_JSON_VALUE))
    public String addEmployeeDetails (
        @RequestBody final EmployeeDTO empDTO) throws ReEncryptionException
    {
        log.info("In AddEmployeeDetails().");
        return reEncryptionService.addEmployeeDetails(empDTO);
    }


   @Transactional
    public String addEmployeeDetails (final EmployeeDTO employeeDTO) throws ReEncryptionException
    {
            final Employee emp = Employee.builder()
                .empName(employeeDTO.getEmpName())
                .creditCardNumber(employeeDTO.getCreditCardNumber())
                .accountNumber(employeeDTO.getAccountNumber())
                .tenantId(employeeDTO.getTenantId())
                .build();
            emp.setEmpAddress(Arrays.asList(
                new Address(11, "abohar"),
                new Address(22, "Bangalore")));
        employeeRepository.save(emp);
        return "Successfully saved Employee details.";
    }
M getting this error. I am trying to add a new Employee.

{
    "timestamp": "2021-06-17T12:50:29.670+0000",
    "status": 500,
    "error": "Internal Server Error",
    "message": "Could not commit JPA transaction; nested exception is javax.persistence.RollbackException: Error while committing the transaction",
    "path": "/addEmployeeDetails"
}

【问题讨论】:

    标签: java hibernate jpa transactions spring-transactions


    【解决方案1】:
    java.lang.UnsupportedOperationException: null
    

    您调用的方法之一未实现。很难说哪个没有错误堆栈跟踪

    【讨论】:

      猜你喜欢
      • 2020-05-11
      • 2021-08-26
      • 2019-02-26
      • 1970-01-01
      • 2013-01-09
      • 2019-04-09
      • 1970-01-01
      • 2022-08-22
      • 2016-07-08
      相关资源
      最近更新 更多