on ‎2019 Feb 04 1:48 PM
Hello,
Is there a way to get the PK of the model which is saved, e.g in below code I want the PK of address since address does not have a 'code' or 'uid'
modelService.save(billingAddressModel);
How can I get the PK of billingAddressModel?
Request clarification before answering.
It is billingAddressModel.getPk() e.g. please test the following groovy code:
p = modelService.create('Product')
p.code = "12345"
p.catalogVersion = catalogVersionService.getCatalogVersion('Default', 'Staged')
modelService.save(p)
print p.getPk();
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You are most welcome.
So basically hybris creates a pk value even before modelService.save() method is called.
No.
Please check the comment given below:
p = modelService.create('Product')
p.code = "12345"
p.catalogVersion = catalogVersionService.getCatalogVersion('Default', 'Staged')
println p.getPk(); // returns null
modelService.save(p)
println p.getPk(); // returns the PK e.g. 8796355264513
billingAddressModel.getPk()
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.