sap-commerce-db-sync
sap-commerce-db-sync copied to clipboard
Datatype of java.lang.Character not correctly created in Schema-Migration
Attributes of the type java.lang.Character have the data type SAMLLINT in a MySQL Database
e.g. 'grouptSeperator' on Language:
<attribute generate="true" autocreate="true" qualifier="groupingSeparator" type="java.lang.Character">
<persistence type="property" qualifier=""/>
<modifiers read="true" write="true" search="true" encrypted="false" optional="true" removable="true" initial="false"
unique="false" private="false" partof="false"/>
</attribute>
When executing a schema migration to an MS SQL-Server database, the samllint data type gets assigned to INTEGER which will cause errors after the database-sync when editing the 'groupSeperator` field.
The function writeValue(PreparedStatement stmt, int fieldIndex, Character value) in de.hybris.platform.persistence.property.JDBCValueMappings is explicitly checking if the used database is SQLServer and if this is the case it uses PreparedeStatement.setString(...) to set the Character value, which will cause an error since the type of the database column is INTEGER.
The type of java.lang.Character Columns should be CHAR(4) (This is the case when initizalizing an SQL-Server database)
We're aware of this limitation, however DB Sync is more JDBC based ETL tool, unaware of hybris type system specifics, such as mentioned by you, custom column types in DB for certain attributes. Such is driven by mapping from platform/ext/core/resources/core-advanced-deployment.xml so if you want to ensure that target schema will be compatible with hybris expectations, generate DDL from initialization and use this as a reference.