简体   繁体   English

找不到能够从类型 [java.util.LinkedHashMap 进行转换的转换器<?, ?> ] 输入

[英]No converter found capable of converting from type [java.util.LinkedHashMap<?, ?>] to type

I have documents like this in a couchbase DB我在沙发数据库中有这样的文件

{

  "hostel": {
    "city": {}
    ...
  }
}

and I have this query defined in a repository我在存储库中定义了这个查询

@Query("UPDATE #{#n1ql.bucket} SET hostel.state = $2 where hostel.id=$1 RETURNING #{#n1ql.bucket}.hostel    ")
Hostel update(String entityId, String newState);

but when I run it I got this error:但是当我运行它时,我收到了这个错误:

org.springframework.core.convert.ConverterNotFoundException: 
No converter found capable of converting from type [java.util.LinkedHashMap<?, ?>] to type [com.model.Hostel]

and the Hostel type:和旅馆类型:

@Data
@Builder
@AllArgsConstructor
@JsonInclude(NON_NULL)
@EqualsAndHashCode
public class Hostel {

    private @NotNull String id;
    private @NotNull String city;
    private JsonObject commodities;
}

I also tried with:我也试过:

@Query("UPDATE #{#n1ql.bucket} SET hostel.state = $2 where hostel.id=$1 RETURNING #{#n1ql.bucket}.hostel    ")
void update(String entityId, String newState);

but then I got the error:但后来我得到了错误:

org.springframework.data.couchbase.core.CouchbaseQueryExecutionException: Query returning a primitive type are expected to return exactly 1 result, got 0

According to Spring Data: Modifying Query根据Spring Data:修改查询

You can specify the following return types:您可以指定以下返回类型:

  • void空白

  • int (updated record count) int(更新记录数)

  • boolean(whether a record was updated)布尔值(记录是否更新)

In your case you have return type Hostel what is not good if you are using SpringData .在您的情况下,如果您使用SpringData您的返回类型为Hostel是不好的。 Spring can not convert result of query execution to Hostel type. Spring 无法将查询执行的结果转换为Hostel类型。 Try to use one of type specified earlier尝试使用之前指定的类型之一

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 找不到能够从类型 [java.util.LinkedHashMap 进行转换的转换器<?, ?> ] 输入 [java.lang.String] - Spring 配置服务器 - No converter found capable of converting from type [java.util.LinkedHashMap<?, ?>] to type [java.lang.String] - Spring config server 春季启动2:ConverterNotFoundException:未找到能够从类型[java.time.ZonedDateTime]转换为类型[java.util.Date]的转换器 - Spring boot 2 : ConverterNotFoundException: No converter found capable of converting from type [java.time.ZonedDateTime] to type [java.util.Date] 找不到适合请求类型 [java.util.LinkedHashMap] 和内容类型 [multipart/form-data] 的 HttpMessageConverter - no suitable HttpMessageConverter found for request type [java.util.LinkedHashMap] and content type [multipart/form-data] 如何使用java.util.LinkedHashMap $ EntryIterator类型访问对象值 - How to access the object value with java.util.LinkedHashMap$EntryIterator type MongoDB 找不到能够从 [java.lang.String] 类型转换为 [java.time.LocalDateTime] 类型的转换器 - MongoDB No converter found capable of converting from type [java.lang.String] to type [java.time.LocalDateTime] 没有找到能够将[java.lang.Long]类型转换为[User]类型的转换器 - Grails No converter found capable of converting from type [java.lang.Long] to type [User] 找不到能够从类型 org.bson.BsonUndefined 转换的转换器 - No converter found capable of converting from type org.bson.BsonUndefined 存储功能错误:未找到能够从类型转换的转换器 - Stored Function Error: No converter found capable of converting from type SPRING REDIS - 找不到能够从类型转换的转换器.. 错误 - SPRING REDIS - No converter found capable of converting from type.. ERROR Spring&Couchbase-找不到能够将[java.lang.Long]类型转换为[java.sql.Timestamp]类型的转换器 - Spring & Couchbase - No converter found capable of converting from type [java.lang.Long] to type [java.sql.Timestamp]
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM