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

Smartedit: Relation partof doesn't save target element

706

I have a custom component with multiple items. Here is the definition of the relation.

<relation code="MyComponent" autocreate="true" localized="false">
<sourceElement type="MyComponent" qualifier="component" cardinality="one">
<modifiers optional="true" />
</sourceElement>
<targetElement type="MyItem" cardinality="many" qualifier="item" collectiontype="set">
<modifiers optional="true" partof="true"/>
</targetElement>
</relation>

In Smartedit I wrote a custom editor for the Point. When I am saving my component in smartedit, I get following exception.

de.hybris.platform.servicelayer.exceptions.ModelSavingException: [de.hybris.platform.servicelayer.interceptor.impl.UniqueAttributesInterceptor@30dc0583]:ambiguous unique keys {code=UniqueCode} for model MyItemModel (<unsaved>) - found 1 item(s) using the same keys
at de.hybris.platform.servicelayer.internal.model.impl.wrapper.ModelWrapper.invokeValidateInterceptors(ModelWrapper.java:300) ~[coreserver.jar:?]
at de.hybris.platform.servicelayer.internal.model.impl.wrapper.ModelWrapper.validate(ModelWrapper.java:237) ~[coreserver.jar:?]
at de.hybris.platform.servicelayer.internal.model.extractor.impl.DefaultModelExtractor.process(DefaultModelExtractor.java:50) ~[coreserver.jar:?]
at de.hybris.platform.servicelayer.internal.model.impl.DefaultModelService.performPersistenceOperations(DefaultModelService.java:708) ~[coreserver.jar:?]
at de.hybris.platform.servicelayer.internal.model.impl.DefaultModelService.saveAllInternal(DefaultModelService.java:703) ~[coreserver.jar:?]
at de.hybris.platform.servicelayer.internal.model.impl.DefaultModelService.saveAll(DefaultModelService.java:683) ~[coreserver.jar:?]
at de.hybris.platform.servicelayer.internal.model.impl.DefaultModelService.saveAll(DefaultModelService.java:637) ~[coreserver.jar:?]

So I proceeded to write a custom converter. So I can save my item myself.

<bean id="itemAttributeToDataContentConverter" class="packet.converters.MyItemAttributeToDataContentConverter" />
<bean id="itemDataToAttributeContentConverter" class="packet.smartedit.converters.MyItemDataToAttributeContentConverter" />
<bean id="itemPredicate" class="packet.smartedit.predicates.MyItemAttributePredicate" />

<bean name="myItemContentConverter" parent="cmsAbstractContentConverter"
p:modelToDataConverter-ref="itemAttributeToDataContentConverter"
p:dataToModelConverter-ref="itemDataToAttributeContentConverter"
p:constrainedBy-ref="itemPredicate">
</bean>

But it didn't work. When debugging I found out, that my predicate didn't work.

I narrowed it down to a simple problem. My Item has a RelationDescriptorModel and not a AttributeDescriptorModel.

I changed the Predicate to implement RelationDescriptorModel

public class VzugPointAttributePredicate implements Predicate<RelationDescriptorModel> {

This didn't work. The error message said: "cannot cast from RelationDescriptorModel to AttributeDescriptorModel.


I need help to either get the save feature of hybris to work, or to get my converter working.


Thank you for your help

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

I removed partof from MyItem.This fixed it.

Answers (0)