meta data for this page
  •  

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
sap_hybris_commerce:sap_hybris_persistence_mechanism [2019/12/18 19:44] – external edit 127.0.0.1sap_hybris_commerce:sap_hybris_persistence_mechanism [2022/11/25 08:06] (current) – [One to many relations] Antonio Robirosa
Line 91: Line 91:
     * The field can only be written once (initial=true)     * The field can only be written once (initial=true)
     * The field must be removed when the parent Item is removed (partof=true)     * The field must be removed when the parent Item is removed (partof=true)
 +
 +<WRAP center round important 100%>
 +Hybris don't trigger the remove interceptors when updating a partof relations. If a base product is updated with a **subset** of the variants which are on the database, **the missing variants will be removed** and you can't use a remove interceptor to prevent the deletion. This happens on SAP commerce 1905. \\
 +To really prevent the removal of products from the database you need a database trigger like the following one for Microsoft SQL Server:
 +<code>
 +return jaloSqlScriptService.runDeleteOrUpdateStatement("CREATE OR ALTER TRIGGER PRODUCTS_DEL ON products INSTEAD OF DELETE AS THROW 51000, 'Products must not be deleted', 1")
 +
 +</code>
 +This code create database trigger preventing any removal of products. It depends on [[https://github.com/arobirosa/areco-deployment-script-manager/wiki|Areco Deployment Script Manager]]
 +
 +</WRAP>
 +
     * The field is part of the secondary key and must be **unique** inside the cluster of servers (unique=true). A group of attributes could be unique. The validation is done by Hybris using Java code. As two threads may store two items with the same unique values on the database, you have to use database transactions to be sure that the fields are unique across the cluster of servers     * The field is part of the secondary key and must be **unique** inside the cluster of servers (unique=true). A group of attributes could be unique. The validation is done by Hybris using Java code. As two threads may store two items with the same unique values on the database, you have to use database transactions to be sure that the fields are unique across the cluster of servers
     * [[https://help.hybris.com/6.5.0/hcd/8bff7a568669101488a5e40cb7bbd0b9.html#itemsxmlelementreference-type_modifierstype|Other modifiers]]     * [[https://help.hybris.com/6.5.0/hcd/8bff7a568669101488a5e40cb7bbd0b9.html#itemsxmlelementreference-type_modifierstype|Other modifiers]]
Line 174: Line 186:
 This example creates the column **customer** in the table where the items EmailAddress are stored and getters and setters on the customers to set and get the list of emails. The sourceElement and targetElement may have modifiers like the attributes. You have to read the source and target elements XML tags crossed to understand where the setters and getters are generated. This example creates the column **customer** in the table where the items EmailAddress are stored and getters and setters on the customers to set and get the list of emails. The sourceElement and targetElement may have modifiers like the attributes. You have to read the source and target elements XML tags crossed to understand where the setters and getters are generated.
  
 +One to many relations cannot be localized. You have to use a many to many relationship and manage the removal of associations.
 ===== Many to many relations ===== ===== Many to many relations =====