在java中作为null插入的外键列

时间:2018-02-17 13:16:25

标签: java hibernate

code of entities 'employee' and 'timelog'问题: 我有两个表employee和timelog.Timelog与employee表(employee id)有外键关系。但是每个插入到timelog表的员工id都是null.Below是模型' employee'的代码片段。和' timelog'和逻辑。

@RequestMapping(path = "employee/{id}/timelog/tabdata",method = RequestMethod.POST,consumes = MediaType.APPLICATION_JSON_VALUE)
    public void timeLogging(@RequestBody ArrayList<TimeLogDto> tabData, @PathVariable("id") Integer id){
        Employee e = employeeRepository.findOne(id);        
        tabData.forEach(log->{
            e.addLog(timeLogRepository.save(log.createTimeLog()));
        });

感谢任何帮助。

0 个答案:

没有答案
相关问题