如何在hybris programmetcally创建新的员工

时间:2017-04-21 10:05:52

标签: hybris

我无法使用以下代码创建新用户:

final EmployeeModel empl=new EmployeeModel();
empl.setUid("test");
modelService.save(empl);

2 个答案:

答案 0 :(得分:2)

另外,请勿执行此操作:new EmployeeModel();

您应始终使用ModelService创建ItemModel的新实例:

modelService.create(EmployeeModel.class)

使用modelService,它将通过任何为此类型定义的拦截器,然后可以初始化项目的默认值。使用new运算符时。它不会设置默认值,并可能导致您遇到的错误。

答案 1 :(得分:0)

此代码适用于开箱即用的hybris。 您可能已自定义员工类型并添加了必填字段。 检查错误详细信息,您可能会找到错过的字段。