如何为 Java Final String 查询正确翻译我的灵活搜索查询?
How can I translate my flexible search query properly for a Java Final String query?
我正在尝试在 Hybris Commerce 上为来自模型的 return 数据创建一个网络服务。我的查询适用于灵活的搜索控制台,但我在 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%'
你的错误在这里:
"SELECT * FROM {a: " + AddressModel._TYPECODE
删除 "a:" 即可。
我正在尝试在 Hybris Commerce 上为来自模型的 return 数据创建一个网络服务。我的查询适用于灵活的搜索控制台,但我在 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%'
你的错误在这里:
"SELECT * FROM {a: " + AddressModel._TYPECODE
删除 "a:" 即可。