cancel
Showing results for 
Search instead for 
Did you mean: 

Modifying column type of existing attribute doesn't work

Former Member
0 Kudos

Dear Experts,

we have the problem that we have to increase the column size of one of our type's attributes, which should be possible according to https://wiki.hybris.com/display/release5/items.xml#items.xml-MakeColumnTypesChangeableDuringUpdateSy...

To make sure it's not a project related problem i tried the following with vanilla accelerator 5.1:

  1. Initialize the vanilla accelerator

  2. Change attribute style of ApparelStyleVariantProduct in yacceleratorcore-items.xml from

    Color/Pattern of the product. to

    Color/Pattern of the product. HYBRIS.LONG_STRING

  3. run ant

  4. restart server

  5. update running system

  6. restart server

Doing so, it is still not possible to put a string with more than 255 characters into attribute "style" in hmc:

 The item could not be saved due to the following errors: sql error saving EJBPropertyRowCache[itemPK:null,langPK:8796093055008,inDB:true,hasChanged:true,names:[articleStatus, description, manufacturerTypeDescription, name, segment, style, summary],values:[null, null, null, Panorama Pants Women beet red, null, Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec., null],changeList:{5}]:1988741175 for item 8796258533377 , query = UPDATE productslp SET p_style = ? ,ITEMTYPEPK = ? WHERE ITEMPK = ? AND LANGPK = ? values = [Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec., 8796133195858, 8796258533377, 8796093055008]java.sql.SQLDataException: data exception: string data, right truncation

Thanks for help!

Regards, Norbert

PS: Note that i only tested on HSQLDB.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

If you're only changing the size and not changing the type then you can just do an "alter column" on the database

indrit79
Explorer
0 Kudos

Ah ok, but we already knew that. We're expecting that Hybris did that via update system as described at the beginning of this thread...

???

Answers (5)

Answers (5)

Former Member
0 Kudos

I am using HSQLDB and removal of column in items.xml and ant update is not removing the column in DB. I tried alter table form hac -- SQL Query 'ALTER TABLE DROP [COLUMN] ;' which did not work saying it is not a DML and DQL.

Questions for experts out there:

So DDLs are not allowed in HAC? This seems weird, since in real time there will be cases when we have to run DDLs on DB.

What options do we have. Initialize is definitely not the way to go when we are talking about PROD environment.

Please advise.

Former Member
0 Kudos

These operations are related to the DB engines.
1. Size increasing of varchar: System Update can do it (varchar2 in case of Oracle)
2. Changing the type from varchar to text (for MySQL and MsSQL): System Update can do it (but range violation can occur on MySQL)

Former Member
0 Kudos

So in fact i have to know what happens on the database when modifying the column type in items.xml:

  1. if the column type stays the same and only size increases (e.g. varchar(255) to varchar(500)), performing update running system won't help; you have to change the size manually using alter table

  2. if the column type changes (varchar(255) -> text), update running system will do it; no manual execution of alter table statements necessary

Former Member
0 Kudos

Thanks for your reply! According to wiki it should work though:

Starting with version 4.1.0, the hybris Commerce Suite can change the type of database table columns during an update process. Technically, this runs ALTER statements on the respective database table column and therefore changes the persistence setting of attributes directly on the database. For example, you can modify a database table column from CHAR(255 to VARCHAR(255) or vice versa.

Moreover the answers of question https://answers.sap.com/questions/12748353/alter-column-to-increase-size.html also state that it should work without an initialization.

Former Member
0 Kudos

since update process will not remove and create column, you need to run initialize again. If you don't want to lose your data then you have to manually alter that particular column.