can service-builder update key value?

Scarletake Bwi, modified 3 Years ago. Expert Posts: 327 Join Date: 12/20/10 Recent Posts

hi 

i use service-builder. for a case, i have to update pk value, but after i set the value and call the update, there have no exception, but the data doesn't change.

can the pk value be update?

 

update my question

i try create a new, and delete old.

	public XIII getXIII(String material, long plant) {
		XIII xiii = null;
		XIIIPK pk = new XIIIPK(material, plant);
		try {
			xiii = this.getXIII(pk);
		} catch (Exception ex) {
		}
		if (xiii == null) {
			try {
				Item item = ItemLocalServiceUtil.getItem(material);
				XIIIPK oldKey = new XIIIPK(item.getItemNumber(), plant);
				XIII temp = this.getXIII(oldKey);
				if (temp != null) {
					xiii = this.addXIII(this.createXIII(pk));
					xiii.setCountryCode(temp.getCountryCode());
					xiii.setCompanyCode(temp.getCompanyCode());
					xiii.setSequence(temp.getSequence());
					xiii.setCheckCode(temp.getCheckCode());
					xiii.setNote(temp.getMaterialNumber());
					this.updateXIII(xiii);
					this.deleteXIII(temp);
					LOGGER.info("Replace "+item.getItemNumber()+" to "+material);
				}
			} catch (Exception ex) {
				LOGGER.error(ex);
			}
		}else {
			LOGGER.info("get data by key "+pk.toString());
		}
		return xiii;
	}

 

i call it two times

first time, the log show

2022-02-16 10:57:35.363 INFO  [http-nio-8080-exec-4][XIIILocalServiceImpl:180] Replace 100-21-1300-00 to LP-41300

second time, the log show
2022-02-16 10:58:51.020 INFO  [http-nio-8080-exec-23][XIIILocalServiceImpl:186] get data by key {materialNumber=LP-41300, plant=7601}
 

it mean it can get data via service builder's qurey. but i check from db, doesn't change, and after restart server, it all back.