on 2019 May 09 8:22 AM
Why Hybris stores enumeration in Enumeration values table even if Custom Enumeration table is created which has all the values of our custom enums.
Request clarification before answering.
Hi - the reason is the dynamic nature of hybris enumtype. As you may be already aware, you can declare an enumtype to be dynamic e.g.
<enumtypes>
<enumtype code="TestForEnum" autocreate="true" generate="true" dynamic="true">
<value code="Test1"/>
<value code="Test2"/>
</enumtype>
</enumtypes>
which makes it possible to add new values to the enum by runtime e.g. you can execute the following groovy code in hAC:
import de.hybris.platform.core.model.enumeration.EnumerationValueModel;
EnumerationValueModel model = (EnumerationValueModel)modelService.create("TestForEnum");
model.setCode("Test3");
model.setName("Test3");
modelService.save(model);
//Note: make sure COMMIT is switched on
and then check the new value created in the database using the following FS Query:
SELECT * FROM {enumerationvalue} WHERE {code}='Test3'
Thus, a database table is required to enable this feature.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.