cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Model Refresh not working as expected for referenced models.

100542E11
Explorer
0 Likes
1,407

Hello experts, We are actually facing an issue where we have two models.

  1. PaymentTransactionModel

  2. AbstractOrderModel

    paymentTransactionModel.setOrder(abstractOrderModel) ; modelService.save(paymentTransactionModel); modelService.refresh(paymentTransactionModel);

when we do debug these lines, we can see that the third step is not refreshing the abstractOrderModel(This doesn't hold paymentTransactionModel).

Note: Sometimes we put debug point after line three it works and refreshes the abstractOrderModel. In this case abstractOrderModel contains the paymentTransactionModel. But otherwise, it doesn't.

And in the next consecutive steps, when the cart is cloned into the order(OOTB). As there is no paymentTransactionModel set in the cart, OrderModel also doesn't contain paymentTransactionModel.

Can anybody help to understand this inconsistent behavior?

version: 6.7.0.1

Accepted Solutions (0)

Answers (2)

Answers (2)

agrabovskis
Participant
0 Likes

It should be like this:

 paymentTransactionModel.setOrder(abstractOrderModel) ;
 modelService.save(paymentTransactionModel);
 modelService.refresh(abstractOrderModel);

You have to refresh the order (not transaction) to force order to be reloaded from database and thereby fetch the added references.

100542E11
Explorer
0 Likes

Yes Arvids, Couldn't agree more. But again the question is : Why is sometimes abstractOrderModel have the reference of paymentTransactionModel without getting refreshed? I am facing this problem with Hybris v6.7.

bidyadhar_tripathy
Participant
0 Likes

Hi Ishwar,

Instead of modelService.save(paymentTransactionModel) , can you please use below statement and try.

 modelService.saveAll(abstractOrderModel, paymentTransactionModel);
100542E11
Explorer
0 Likes

Hi Bidyadhar, Thanks for the reply! Below are the ways to explicitly save or refresh abstractOrderModel.

 modelService.save(abstractOrderModel)
 OR
 modelService.refresh(abstractOrderModel)
 OR 
 modelService.saveAll(...)


But I am afraid, I can't do any changes in the code (Third party code). So in order to resolve this, Need to figure out if this is OOTB bug or anything is wrong with the code. Then I can move ahead with the respective solution and follow with for the same.