on ‎2020 Apr 28 5:38 AM
Hello !
I want to override media type and make its codeVersionIDXindex non unique , I read about replace='true' and remove='true' but not sure about the impact as hac system update wont remove old index from db !
How to achieve this ?
<itemtype code="MediaContainer" autocreate="false" generate="false"> <custom-properties> <property name="catalogItemType"><value>java.lang.Boolean.TRUE</value></property> <property name="catalogVersionAttributeQualifier"><value>"catalogVersion"</value></property> <property name="uniqueKeyAttributeQualifier"><value>"qualifier"</value></property> <property name="catalog.sync.default.root.type"><value>Boolean.TRUE</value></property> <property name="catalog.sync.default.root.type.order"><value>Integer.valueOf(8)</value></property> </custom-properties> <attributes> <attribute qualifier="catalogVersion" type="CatalogVersion"> <modifiers read="true" write="true" search="true" optional="false" unique="true"/> <persistence type="property"/> </attribute> </attributes> <indexes> <index name="versionIDX" unique="false"> <key attribute="catalogVersion"/> </index> <index name="codeVersionIDX" unique="true"> <key attribute="qualifier"/> <key attribute="catalogVersion"/> </index> </indexes> </itemtype>
Many Thanks !
Vaibhav
Request clarification before answering.
In Hybris you can extend ItemTypes. For this you need to define the ItemType in your custom-items.xml .
To remove an Unique Index is not possible and not recommendet as these Indexes make sure that only one Object of the given Type and unique Attributes exists. Therefore instead of removing the Index replace it and add your custom Field to the existing Index keys as shown below.
<itemtype code="MediaContainer" generate="false" autocreate="false">
<attributes>
....
</attributes>
<indexes>
<index name="codeVersionIDXindex" unique="true" replace="true">
<key attribute="qualifier"/> <!-- hybris standard -->
<key attribute="catalogVersion"/> <!-- hybris standard -->
<key attribute="myCustomField"/>
</index>
</indexes>
</itemtype>
EDIT:
I've found the following Issue in sap Jira: https://cxjira.sap.com/browse/ECP-3194
https://dev.mysql.com/doc/refman/5.7/en/create-index.html#create-index-unique
This means all unique (code, catalogVersion) index that are defined by the platform don't behave as expected, as for all the affected types you can leave the catalogVersion NULL. (CatalogUnawareMedia, for example)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks stefankruk for your view !
When we add unique="true" and replace="true" it will replace the older index with new but it will remain unique=true only , I m looking to make this index non unique , Let me explain the case
My older hybris version is 1808 where Media type codeVersionIDXindex Index unique attribute is true in xml but when I look at database I see this index prop with unique NO in Information / definition tab (mysql db). If that was done with hybris code then item.xml should have codeVersionIDXindex unique="false" replace='true' but its very strange to see item.xml says unique=true but DB says No
As per my knowledge index property cant be modified with query either we can add or drop index but changing index unique prop to No is not possible (Unless someone did drop and recreate index with unique NO, And we dont have any record info on this)
Now in 1905 , At code level there is no difference and Media type codeVersionIDXindex index is still unique=true in xml, But again strange thing .. in 1905 Database properties of this index (which was NO in 1808 and same DB is being referred ) shows unique YES !! after 1905 system update
How this has happened ? because only initialization can update the index prop unique YES/NO in DB Or index prop removed=true/replaced=true and ran system update , We did nothing of both the scenarios
Do you have any guess why index unique No prop got modified to YES in 1905 where no initialization or removed/replaced and ran system update happened
As this was NO in 1808 , some duplicate entries are present in DB and now while system update these are creating trouble (Ideally duplicate entry should not be there) But we are just searching for the cause why its set to YES in DB on 1905
Many thanks !
Vaibhav
I Updated my answere above. It seems that this is already a known issue: https://cxjira.sap.com/browse/ECP-3194
Please have a look if it matches your problem.
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 1 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.