从ofbiz

时间:2017-11-14 17:45:12

标签: ofbiz

任何人都可以帮助我恳求,我有一个名为Person的实体,并且可以从这个实体延伸出来 所以我想添加一个业余的问题,我需要表的ID人我怎么能得到它PLZ

public static Map<String, Object> createFormateur(DispatchContext dctx, Map<String, ? extends Object> context) {
Map<String, Object> result = ServiceUtil.returnSuccess();
Delegator delegator = dctx.getDelegator();
try {
    GenericValue formateurAdd = delegator.makeValue("twFormateur");


    formateurAdd.setString("partyId", context.toString());

    formateurAdd.setNonPKFields(context);
    // Creating record in database for OfbizDemo entity for prepared value
    formateurAdd = delegator.create(formateurAdd);
    result.put("partyId", formateurAdd.getString("partyId"));
    Debug.log("==========Thisis my first Java Service implementation in Apache OFBiz. OfbizDemo record created successfully with ofbizDemoId: "+formateurAdd.getString("partyId"));
} catch (GenericEntityException e) {
    Debug.logError(e, module);
    return ServiceUtil.returnError("Error in creating record in OfbizDemo entity ........" +module);
}
return result;

}

1 个答案:

答案 0 :(得分:1)

如果您需要从上下文获取单个密钥,例如partyId,您可以尝试:

String partyId = (String)context.get("partyId");

在这种情况下,您可能希望将上下文的所有信息填充到GenericValue中,您可以尝试:

GenericValue formateurAdd = delegator.makeValidValue("twFormateur", context);