无法使用具有春季启动功能的swagger API文档和具有一键式关系的表将数据持久保存在数据库中?

时间:2018-09-13 09:24:12

标签: java spring-boot swagger-ui

下面是控制器代码:

@RequestMapping(value="/{empId}" ,method=RequestMethod.GET)
ResponseEntity<Employee> getEmpById(@PathVariable("empId") Integer empId){
    Employee emp=null;
        try{
            emp=empService.getEmpById(empId);
            log.debug("employee_controller - getting employee of id...."+empId);
        }catch(Exception e) {
            log.error("employee_controller - error occured while getting employee" +e);
        }
    return new <>(emp,HttpStatus.OK);    }

下面是服务代码:

 public Employee getEmpById(Integer empId) {

        Employee emp = null;
        try {

            log.debug("Employee_Service - getting employee by id..." + empId);
            emp = empDao.findOne(empId);
            System.out.println("emp data is========" + emp);
        } catch (Exception e) {
            log.error("Employee_Service - errror occured during getting employee of id" + empId);
        }
        return emp;
    }

强调文本:在获取表时获取null甚至无法持久存储数据(如果表)      有很多关系。如果我删除关系,那会很好。

InputType

stacktrace **休眠:     选择         员工0_.empid为empid1_1_1_,         employee0_.empname作为empname2_1_1_,         dept1_.empid为empid3_0_3_,         dept1_.deptid作为deptid1_0_3_,         dept1_.deptid作为deptid1_0_0_,         dept1_.deptname作为deptname2_0_0_,         dept1_.empid为empid3_0_0_     从         emp_tbl员工0_     左外连接         部门部门1             在employee0_.empid = dept1_.empid上     哪里         employee0_.empid =? 2018-09-13 15:22:58-将参数1绑定为[INTEGER]-1 休眠:     插入     进入         emp_tbl         (empid,empname)     价值观         (空值, ?) 2018-09-13 15:22:58-绑定参数1为[VARCHAR]-[john] 休眠:     选择         dept0_.deptid作为deptid1_0_1_,         dept0_.deptname作为deptname2_0_1_,         dept0_.empid为empid3_0_1_,         employee1_.empid为empid1_1_0_,         employee1_.empname作为empname2_1_0_     从         部门部门     左外连接         emp_tbl员工1_             在dept0_.empid = employee1_.empid上     哪里         dept0_.deptid =? 2018-09-13 15:22:58-绑定参数1为[INTEGER]-[2] 2018-09-13 15:22:58-Employee_Service-在保存employeecom.hcl.ontToManyWithH2.Entities.Employee@799f9b7c期间发生错误

2018-09-13 15:22:58-employee_controller-保存employeecom.hcl.ontToManyWithH2.Entities.Employee@799f9b7c **

0 个答案:

没有答案