1

I am trying to increase column size to 1024 characters from default 255 characters. Note that this is an existing production item type(AbstractOrderEntry) & attribute(productDescription). system init is not possbile.

So far I have tried these 2 approaches.

  1. Modified *-items.xml file.

           <attribute qualifier="productDescription" type="java.lang.String">
                <modifiers unique="false" optional="true" read="true" write="true"/>
                <persistence type="property">
                    <columntype database="oracle">
                        <value>varchar(1024)</value>
                    </columntype>
                    <columntype database="sqlserver">
                        <value>nvarchar(1024)</value>
                    </columntype>
                    <columntype database="hsqldb">
                        <value>VARCHAR(1024)</value>
                    </columntype>
                    <columntype>
                        <value>varchar(1024)</value>
                    </columntype>
                </persistence>
            </attribute>
    
  2. ant clean all & system update. Didn't work

Other approach was: Executed alter statement from mySql Workbench.

ALTER TABLE `hybrisDB`.`quoteentries` CHANGE COLUMN `p_productdescription` `p_productdescription` VARCHAR(1024) NULL DEFAULT NULL ;

I could see that column size was increased from SQL workbench. But when I'm trying to save the value from Hybris, It throws runtime exception.

INFO   | jvm 1    | main    | 2019/11/26 14:27:20.262 | com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column 'p_productdescription' at row 1
INFO   | jvm 1    | main    | 2019/11/26 14:27:20.262 |         at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4118)
INFO   | jvm 1    | main    | 2019/11/26 14:27:20.262 |         at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4052)```


Restarted Hybris after executing direct SQL statement from DB. 

Any other inputs?
BNR
  • 89
  • 2
  • 13
  • I went with direct SQL statement approach. In fact, I had to do 3 sql statements - **cartentries**, **quoteentries**, **orderentries** – BNR Nov 27 '19 at 19:05
  • Also, with direct SQL update, I don't have to do _updatesystem_ / _restart hybris_. – BNR Nov 27 '19 at 19:12

3 Answers3

1

In your question, you mentioned 2 approaches. I think you can manage to achieve your objective by combining both the approaches i.e.,

  1. Modify $exntesion-items.xml --> ant clean all --> ant updatesystem
  2. Run alter statement on database directly and start Hybris

Related : An excerpt from sap wiki :

enter image description here

Reference : help.sap.com

www.hybriscx.com
  • 1,129
  • 4
  • 22
0

You can try to redeclare the attribute.

 <attribute qualifier="productDescription" redeclare="true" type="java.lang.String">
   <modifiers read="true" write="true" optional="true" unique="false" />
     <persistence type="property">
      <columntype>
          <value>HYBRIS.LONG_STRING</value>
      </columntype>
     </persistence>
</attribute>
Joe Sebin
  • 452
  • 4
  • 24
  • 1
    Hi Joe - Redeclare can only be applied to attributes from an Abstract Item Type or when you extend an item then you can re-declare it in Child/Sub item-type. Else system will give you a compilation error. So it will work but only when one has extended item. – www.hybriscx.com Nov 27 '19 at 06:51
  • It will not always work and will end up in compilation error : (AttributeTagListener)][null] - no super attribute though attribute is inherited or redeclared – user May 11 '20 at 09:07
0

I would create a new attribute (in items.xml) with the required size, rebuild and perform a system update, migrate the data from the existing attribute (using ImpEx) and adjust the application code accordingly. It won't be too much effort and it will be the safest thing to do.

However, if you still want to do it with the existing attribute, please make sure you have backed up your data before performing any of the following things:

A. Change the items.xml as follows:

<persistence type="property">
    <columntype database="mysql">
        <value>TEXT</value>
    </columntype>
    <columntype>
        <value>varchar(1024)</value>
    </columntype>
</persistence>

You have missed to mention database="mysql" in the XML you have posted in the question.

B. Execute ant clean all updatesystem and test your application.

C. If it doesn't work, execute the SQL ALTER command you have already done; but this time, make sure to execute system update as well after executing the ALTER command.

Arvind Kumar Avinash
  • 71,965
  • 6
  • 74
  • 110