gpt4 book ai didi

java - 如何将灵活的搜索查询正确转换为 Java Final String 查询?

转载 作者:行者123 更新时间:2023-11-30 01:46:33 25 4
gpt4 key购买 nike

我正在尝试在 Hybris Commerce 上创建一个 Web 服务以从模型返回数据。我的查询适用于灵活的搜索控制台,但我的 Java 方法存在语法问题。

我的灵活搜索查询:

select * from {address as a join customerenvasado as c on {a:owner} = {c:pk}} where {c:rut} like '1754%' 

我的错误:

{"errors": [{
"message": "type code 'a: owner' invalid",
"type": "FlexibleSearchError"
}]}

我的功能:

public AddressModel getCustomerEnvasadoForRut(String rut) {
validateParameterNotNull(rut, "Rut must not be null!");
final String querys = "SELECT * FROM {a: " + AddressModel._TYPECODE + " as a join " + CustomerEnvasadoModel._TYPECODE + " as c on {a:owner} = {c:pk}} where {c:rut} like ?ParamRut";

final FlexibleSearchQuery query = new FlexibleSearchQuery(querys);
query.addQueryParameter("ParamRut", rut);
List<AddressModel> result = getFlexibleSearchService().<AddressModel>search(querys).getResult();
if (result != null && !result.isEmpty()) {
return result.get(0);
}
return null;
}

最佳答案

只需按如下方式更改您的查询即可,它应该可以工作:

SELECT {pk} FROM {Address AS a JOIN customerenvasado AS c ON {a:owner} = {c:pk}} WHERE {c:rut} LIKE '1754%'

您还可以使用以下查询来代替上面给出的查询:

SELECT {pk} FROM {Address AS a}, {customerenvasado AS c} WHERE {a:owner} = {c:pk} AND {c:rut} LIKE '1754%'

关于java - 如何将灵活的搜索查询正确转换为 Java Final String 查询?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57733389/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com