HotFolder字符串转Warehouse对象:ImpEx翻译器配置报错求助
我们通过外部CSV文件更新StockLevel表,CSV第二列是经销商代码而非实际仓库代码。为此开发了翻译器,用于把经销商代码映射为对应仓库,但执行Impex时出错。移除第二个翻译器后能正常运行,推测是翻译器配置或逻辑有问题,求正确配置方式实现需求。
当前Impex代码
INSERT_UPDATE StockLevel;productCode[unique=true][translator=tau.com.kapa.core.dataimport.stock.QwentaniumStockImportTranslator];warehouse(code)[unique=true][translator=tau.com.kapa.core.dataimport.stock.QwentaniumStockImportDealerTranslator];available "00440-3007";"133180";"1"
错误日志
INFO [AzureIntegrationTaskExecutorThread-master-1] (000099CE) [QwentaniumStockImportDealerTranslator] Number of sellers during SFTP job: 3 INFO [AzureIntegrationTaskExecutorThread-master-1] (000099CE) [QwentaniumStockImportDealerTranslator] Dealer number in SFTP job: 133180 matches with seller: 10814-Goliath ERROR [AzureIntegrationTaskExecutorThread-master-1] (000099CE) [FlexibleSearch] line 3 at main script: Flexible search error occured... WARN [AzureIntegrationTaskExecutorThread-master-1] (000099CE) [ImpExImportReader] line 3 at main script: dumped unresolved line ValueLine[unresolvable:SQL search error - enable the property 'flexible.search.exception.show.query.details' for more details,line 3 at main script,null,HeaderDescriptor[line 2 at main script, insert_update, StockLevel, {}, [productCode, warehouse, available] ],{1=ValueEntry('00440-3007'=00440-3007,unresolved=false,ignore=false), 2=ValueEntry('133180'=WH_STORE02-Goliath,unresolved=false,ignore=false), 3=ValueEntry('1'=null,unresolved=null,ignore=false)}] ERROR [AzureIntegrationTaskExecutorThread-master-1] (000099CE) [CronJobErrorHandler] line 3 at main script: Exception ocurred, will ignore: de.hybris.platform.impex.jalo.ImpExException: SQL search error - enable the property 'flexible.search.exception.show.query.details' for more details[HY--1] de.hybris.platform.impex.jalo.ImpExException: SQL search error - enable the property 'flexible.search.exception.show.query.details' for more details
从日志能看到,经销商代码133180已经被翻译器成功转换为WH_STORE02-Goliath,但后续触发FlexibleSearch报错,说明:
- 翻译后的仓库代码
WH_STORE02-Goliath在系统中不存在,导致Impex找不到对应的Warehouse实例 - 翻译器返回值类型不符合要求:
warehouse(code)字段需要的是Warehouse模型或其有效code字符串,若翻译器返回的内容格式不对,也会导致查询失败
验证翻译器输出的仓库有效性
检查QwentaniumStockImportDealerTranslator的importValue方法,确保返回的仓库code(比如WH_STORE02-Goliath)确实存在于系统的Warehouse表中。可以通过后台HMC/Backoffice搜索Warehouse,确认该code是否存在。调整翻译器返回值类型
如果当前翻译器返回的是字符串,确保是准确的仓库code;也可以修改翻译器逻辑,直接返回Warehouse模型实例(通过FlexibleSearch根据转换后的code查询并返回),这样Impex能直接识别,避免后续查询出错。开启详细FlexibleSearch日志定位问题
在local.properties中添加配置:flexible.search.exception.show.query.details=true重启系统后重新执行导入,此时日志会输出具体的SQL语句和错误详情,能直接看到是仓库不存在还是其他SQL语法问题。
检查Impex字段配置
确认warehouse(code)的翻译器配置位置正确,当前的写法warehouse(code)[unique=true][translator=...]是合法的,但要确保翻译器的逻辑是针对输入的经销商代码做转换,而不是干扰原有字段的查询逻辑。
内容的提问来源于stack exchange,提问作者iamrooovic

