spring boot找不到能够从类型[java.util.LinkedHashMap<?,?>]转换为类型的转换器
我在couchbase数据库里有这样的文件
{
"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
共 (0) 个答案