Programming
hybris: increase maximum field length of attributes
by admin on Feb.20, 2017, under Programming
In hybris, you might want to increase or set the maximum length of a itemtype’s property (attribute) in your database. Besides using the SQL ALTER command, which I am not going to address in this post, this can be achived through your *-items.xml definition as well and I highly recommend using this approach rather than directly messing around with the database.
Assuming you already have an itemtype with an attribute defined as follows:
<attribute type="java.lang.String" qualifier="mySampleAttribute"> <persistence type="property"/> <modifiers read="true" write="true"/> </attribute>
You could extend the tag as shown below, in order to set the maximum length to 512 (instead of e.g. the MySQL default length of 255) on a per-database-basis:
<attribute type="java.lang.String" qualifier="mySampleAttribute"> <persistence type="property"> <columntype database="mysql"> <value>text</value> </columntype> <columntype database="oracle"> <value>varchar2(512)</value> </columntype> <columntype database="sqlserver"> <value>nvarchar(512) null</value> </columntype> <columntype database="hsqldb"> <value>varchar(512)</value> </columntype> <columntype> <value>varchar(512)</value> </columntype> </persistence> <modifiers read="true" write="true"/> </attribute>
Further information can be found on the hybris wiki.