![](/img/trans.png)
[英]No converter found capable of converting from type [java.util.LinkedHashMap<?, ?>] to type [java.lang.String] - Spring config server
[英]No converter found capable of converting from type [java.util.LinkedHashMap<?, ?>] to type
我在沙发数据库中有这样的文件
{
"hostel": {
"city": {}
...
}
}
我在存储库中定义了这个查询
@Query("UPDATE #{#n1ql.bucket} SET hostel.state = $2 where hostel.id=$1 RETURNING #{#n1ql.bucket}.hostel ")
Hostel update(String entityId, String newState);
但是当我运行它时,我收到了这个错误:
org.springframework.core.convert.ConverterNotFoundException:
No converter found capable of converting from type [java.util.LinkedHashMap<?, ?>] to type [com.model.Hostel]
和旅馆类型:
@Data
@Builder
@AllArgsConstructor
@JsonInclude(NON_NULL)
@EqualsAndHashCode
public class Hostel {
private @NotNull String id;
private @NotNull String city;
private JsonObject commodities;
}
我也试过:
@Query("UPDATE #{#n1ql.bucket} SET hostel.state = $2 where hostel.id=$1 RETURNING #{#n1ql.bucket}.hostel ")
void update(String entityId, String newState);
但后来我得到了错误:
org.springframework.data.couchbase.core.CouchbaseQueryExecutionException: Query returning a primitive type are expected to return exactly 1 result, got 0
您可以指定以下返回类型:
空白
int(更新记录数)
布尔值(记录是否更新)
在您的情况下,如果您使用SpringData
您的返回类型为Hostel
是不好的。 Spring 无法将查询执行的结果转换为Hostel
类型。 尝试使用之前指定的类型之一
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.