在Hybris中重新定义items.xml中的数据类型 [英] Redefining data type in items.xml in Hybris

查看:160
本文介绍了在Hybris中重新定义items.xml中的数据类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在items.xml中具有如下定义的数据类型:

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>

更新扩展名后,我得到了SQLException.这种方法有什么问题吗?

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

推荐答案

hybris在运行中"的系统中不支持此类更新. 原因是hybris不会删除任何db列并重新创建它们,因为其中包含的任何数据都会丢失(加上可能很难为多个受支持的数据库编写此逻辑).

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).

如果您使用的是实时系统/生产系统,则必须采用另一种方法: 您将使用枚举类型定义一个新属性(不同的名称!). 然后,您可能会更新任何代码以使用新字段. 您还必须注意数据迁移,即编写一些脚本以传输旧数据(例如,将字符串"Monday"转换为新的各自的枚举值).

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).

希望这会有所帮助!

这篇关于在Hybris中重新定义items.xml中的数据类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆