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

Creating canonical item without primary key in data hub

0 Kudos
499

Hi Experts,

I have a requirement where canonical item needs to be created without primary key. E.g. addressId is not required in Address Item. If I try to do this, I am getting following error:

com.hybris.datahub.validation.ValidationException: [ValidationFailure{FATAL, "No primary key is set for canonical item CanonicalCustomer"}] at com.hybris.datahub.validation.AbstractValidator.validate(AbstractValidator.java:32)

Is there a way to define canonical Item without primary key?

Accepted Solutions (1)

Accepted Solutions (1)

mpern
Product and Topic Expert
Product and Topic Expert
0 Kudos

No, there is no way, because how would you create a canonical item out of your raw item without a primary key to determine a match?

And what happens in case of an update? To use your example: how would you know which Address needs to be updated without some kind of primary key?

0 Kudos

So is there any way to auto generate primary key(Address id in my case) in Data Hub? If yes, How do we do that in our canonical extension xml file?

mpern
Product and Topic Expert
Product and Topic Expert
0 Kudos

I would highly recommend that you get some kind of ID for the address from the source system, for the reasons mentioned above. I bet they do have some kind of identifier, even if you have to be a bit creative (e.g. use the customer ID as address ID, in case a customer can only have a single address)

If that isn't an option, then you have to generate some kind of unique identifier when loading the raw items. Maybe you can write a Spel Expression to generated a GUID in the canonical XML file, or you have to provide it later in the processing with a grouping handler (never tried that).

But you may amass a lot of unnecessary data in SAP Commerce that way. Every address has a new unique id, even updates for existing addresses -> every update is a new address in SAP Commerce, if you don't have some special handling during publish / import of the data in Commerce.

In other words, just because you have the requirement that addresses don't have a primary key, doesn't mean that the requirement makes sense or is even feasible when integrating data.

Answers (0)