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

Why does Hybris stores enumeration values in Enumeration table even though an item type is created for Custom Enumeration table?

Former Member
0 Kudos
3,366

Why Hybris stores enumeration in Enumeration values table even if Custom Enumeration table is created which has all the values of our custom enums.

View Entire Topic
arvind-kumar_avinash
Active Contributor

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.