public Phone addPhone(Long teacherId, Phone model) { if (teacherId == null) { throw new IllegalArgumentException( "Cannot find a " + Teacher.class.getName() + " with a null id."); } if (model == null) { throw new IllegalArgumentException("Cannot persist a null " + Phone.class.getName()); } if (model.getId() != null) { throw new AlreadyDefinedInOnNonPersistedEntity( "Cannot persist a " + Phone.class.getName() + " which already has an ID."); } model = phoneManager.create(model); Teacher fetched = findOneById(teacherId); fetched.getContact().addPhone(model); teacherRepository.saveAndFlush(new TeacherDomain(fetched)); return model; }