cancel
Showing results for 
Search instead for 
Did you mean: 

Some attribute values are coming as null, When I try to fetch the model immediately after saving into DB

Former Member
0 Kudos

We have a requirement in punchout.

Punchout system will send a request to hybris in the form of CXML. In header part of the CXML contains punchoutCredential. We have to authenticate the credential in hybris whether credential is valid Credential or not.

In one scenario if the credential is not available in hybris,we need to create PunchoutCredential on the fly and need to do authentication.

Immediately after saving punchoutcredential I'm trying to fetch the same for authentication. I can able to fetch the punchoutCredentialModel but inside that some attributes are coming as null.But those values are there in DB,I have checked via HMC.

Can you please suggest Why those attribute values are coming null and How to resolve it?

rohit31_raj92
Active Participant
0 Kudos

You need to refresh the model after saving values and then you should try to get values from the model.

Accepted Solutions (1)

Accepted Solutions (1)

former_member620692
Active Contributor
0 Kudos

Hi - please try calling ModelService.refresh(punchoutCredentialModel) before fetching the punchoutCredentialModel.

Former Member
0 Kudos

Hi - Thanks for your Suggestion...

Now it was resolved,

  1. PunchoutCredential

  2. B2BCustomerPunchOutCredentialMapping

  3. B2BCustomer

PunchoutCredential and B2BCustomerPunchOutCredentialMapping is many to one relation. B2BCustomerPunchOutCredentialMapping contains B2BCustomer.

I have created new PunchoutCredential,B2BCustomerPunchOutCredentialMapping & B2BCustomer

Initially I have mapped like below.

 B2BCustomerPunchOutCredentialMappingModel mappingModel = modelService
                 .create(B2BCustomerPunchOutCredentialMappingModel.class);
 mappingModel.setCredentials(punchOutCredentialSet);
 mappingModel.setB2bCustomer(b2bCustomerModel);

Later I have changed like below and it was working fine

 B2BCustomerPunchOutCredentialMappingModel mappingModel = modelService
                 .create(B2BCustomerPunchOutCredentialMappingModel.class);
 mappingModel.setCredentials(punchOutCredentialSet);
 punchOutCredential.setB2BCustomerPunchOutCredentialMapping(mappingModel);
former_member620692
Active Contributor
0 Kudos

You are most welcome.

Answers (0)