-
Notifications
You must be signed in to change notification settings - Fork 15
Description
We are facing issue to map some Tridion component field data to EntityModel object. Some components link fields can be linked to different type of components. So, we have used generic type, EntityModel type of field in the SemanticEntity to map data of the linked component.
But some of the components are throwing following error:
Caused by: com.sdl.webapp.common.api.mapping.semantic.SemanticMappingException: Ambiguous semantic mapping for …
I have investigated the issue and found that DXA framework is failing to map linked component data to EntityModel object if entities for linked component have “entityName” attribute value same as the class name. As the mapping shown below:
@SemanticEntity(entityName = "**Product**", vocabulary = SDL_CORE, prefix = "p")
public class **Product** extends AbstractEntityModel {
…
}
But if we put “entityName” different from class name, as shown below then it is working.
@SemanticEntity(entityName = "**Product**", vocabulary = SDL_CORE, prefix = "p")
public class **ProductObject** extends AbstractEntityModel {
…
}
The issue is occurring because DXA framework register both the value that is specified in “entityName” attribute and entity class name as entity. If both the values are same, then DXA framework finds ambiguous semantic mapping (unable to find unique matching entity for model data) and throws exception.
Can you please let me know if it is limitation of DXA framework or we should follow some naming convention for class name and “entityName” attribute?