问题
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