如何使用服务生成器 liferay 保存自定义实体
how to save custom entity with service builder liferay
如何使用服务构建器 liferay 保存自定义实体?
我创建新实体(名称= BasicProfile)
并由服务构建器 liferay 构建但是
保存时发生异常。
我的代码:
BasicProfile basicProfile = new BasicProfileImpl();
basicProfile.setUserId(11701L);
basicProfile.setBirthCertificateSerial(birthCertificate);
basicProfile.setCreateDate(new Date());
basicProfile.setFatherName(fatherName);
basicProfile.setExtCustId(acceptorNumber);
basicProfile.setMobileNumber(telNumber);
basicProfile.setNationalCode(nationalCode);
basicProfile = BasicProfileLocalServiceUtil.addBasicProfile(basicProfile);
在您的 BasicProfileLocalServiceImpl.java 中创建以下方法:
public BasicProfile create(long userId, String birthCertificate, String fatherName, String acceptorNumber, String telNumber, String nationalCode) throws Exception {
long id = counterLocalService.increment();
BasicProfile obj = createBasicProfile(id);
obj.setUserId(userId);
obj.setBirthCertificateSerial(birthCertificate);
obj.setCreateDate(new Date());
obj.setFatherName(fatherName);
obj.setExtCustId(acceptorNumber);
obj.setMobileNumber(telNumber);
obj.setNationalCode(nationalCode);
obj = updateProduct(obj);
return obj;
}
然后在您的代码中调用该方法来创建一个新对象:
BasicProfile basicProfile = BasicProfileLocalServiceUtil.create(userId, birthCertificate, fatherName, acceptorNumber, telNumber, nationalCode);
如何使用服务构建器 liferay 保存自定义实体? 我创建新实体(名称= BasicProfile) 并由服务构建器 liferay 构建但是 保存时发生异常。 我的代码:
BasicProfile basicProfile = new BasicProfileImpl();
basicProfile.setUserId(11701L);
basicProfile.setBirthCertificateSerial(birthCertificate);
basicProfile.setCreateDate(new Date());
basicProfile.setFatherName(fatherName);
basicProfile.setExtCustId(acceptorNumber);
basicProfile.setMobileNumber(telNumber);
basicProfile.setNationalCode(nationalCode);
basicProfile = BasicProfileLocalServiceUtil.addBasicProfile(basicProfile);
在您的 BasicProfileLocalServiceImpl.java 中创建以下方法:
public BasicProfile create(long userId, String birthCertificate, String fatherName, String acceptorNumber, String telNumber, String nationalCode) throws Exception { long id = counterLocalService.increment(); BasicProfile obj = createBasicProfile(id); obj.setUserId(userId); obj.setBirthCertificateSerial(birthCertificate); obj.setCreateDate(new Date()); obj.setFatherName(fatherName); obj.setExtCustId(acceptorNumber); obj.setMobileNumber(telNumber); obj.setNationalCode(nationalCode); obj = updateProduct(obj); return obj; }
然后在您的代码中调用该方法来创建一个新对象:
BasicProfile basicProfile = BasicProfileLocalServiceUtil.create(userId, birthCertificate, fatherName, acceptorNumber, telNumber, nationalCode);