in How To

How Do You Increase the Database Column Length For An Itemtype Attribute?

In SAP Hybris Commerce 6.x, the default database column length for an Itemtype Attribute String type is 255 characters.  A client recently asked to increase the database column length for the Orders table P_NAME column from the default 255 variable characters length to 500 variable characters length. In this tutorial, I will show you how to properly increase the database column in SAP Hybris Commerce. For this tutorial, I'm using the default Hybris database, HSQLDB.

  1. Open the <Your Hybris DIR>/ext/core/resources/core-items.xmll file using your preferred text file editor.
  2. Once the core-items.xml file is open, find the attribute qualifier="name" under AbstractOrder itemtype node. For example:
  3. Make the following modification to the persistence node:
    <persistence type="property">
     <columntype database="hsqldb>
      <value>varchar(500)</value>
     </columntype>
    </persistence>
    The modification should resemble the following:
     

    *This modification only supports hsqldb, to support MySQL replace hsqldb with mysql

  4.  Next run Hybris Initialization using the hybris administrative console (HAC), if you are performing this tutorial on your local machine goto https://localhost:9002/

  5. Login to the HAC using your admin credentials.
  6. Goto Platform -> Initialization in the main menu
  7. Click on the Initialize button, and keep the Toggle all checkbox selected

    *Note, by performing a Hybris Initialization, your database schema and data will be updated, existing data will be lost.
  8. Several minutes later, the Hybris Initialization will be completed, click on the Continue link to complete the Initialization.
  9.  The Orders table P_NAME column is now 600 variable characters.  The tutorial is complete.
Written By:

Marc is the Founder of HybrisArchitect.com. He enjoys helping others learn more about SAP Hybris Commerce. Marc has held the role of Hybris Architect at Exemplis and Nasty Gal. He is a long-time Java/Spring developer. Marc holds an M.S. Software Engineering from Carnegie Mellon University and a B.S. in Accountancy from California State University, Fresno. He can be reached at: info@hybrisarchitect.com

Add a Comment

Your email address will not be published. Required fields are marked *