Redefining data type in items.xml in Hybris

僤鯓⒐⒋嵵緔 提交于 2019-12-24 08:58:55

问题


I had a datatype defined as follows in items.xml:

 <attribute qualifier="daysOfWeek" type="java.lang.String">
                    <persistence type="property" />
 </attribute>

To modify the data type to enumeration,I redefined it as follows:

             <enumtype code="DaysOfWeek" autocreate="true" generate="true">
                        <value code="Monday" />
                        <value code="Tuesday" />
          </enumtype>

         <attribute qualifier="daysOfWeek" type="DaysOfWeek">
                <persistence type="property" />
      </attribute>

After updating the extension,I am getting SQLException.Is there anything wrong with this approach?


回答1:


hybris doesn't support updates like this in a "running" system. The reason is that hybris won't drop any db columns and recreate them as any data contained in there would be lost (plus its probably difficult to write this logic for multiple supported databases).

If you are in a development phase of your project, the easiest way to fix this is to initialize your system from scratch (i.e. it will drop the database and recreate it).

If you have a live system / production system, you would have to take another approach: You would define a new attribute (different name!) with your enumeration type. You would then probably update any code to use the new field. You would also have to take care of data migration, i.e. write some scripts that transfer the old data (e.g. the String "Monday" to the new respective enum value).

Hope this helps!



来源:https://stackoverflow.com/questions/45849416/redefining-data-type-in-items-xml-in-hybris

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!