[英]SPRING REDIS - No converter found capable of converting from type.. ERROR
[英]Stored Function Error: No converter found capable of converting from type
我在PostgreSQL中创建了存储函数。 我在PostgreSQL中得到了正确的结果。 但是当我尝试使用本机查询调用spring数据jpa中的存储函数时。 我收到了以下错误。
No converter found capable of converting from type [org.springframework.data.jpa.repository.query.AbstractJpaQuery$TupleConverter$TupleBackedMap] to type [com.spacestudy.model.ClientRT]"
知识库
@Repository
public interface ClientRoomTypeRepository extends JpaRepository<ClientRoomType, Integer> {
@Query(nativeQuery = true,value = "select * from roomtype(:int_inst_id)")
List<ClientRT> roomtype(@Param("int_inst_id")Integer int_inst_id);
}
结果类ClientRT
public class ClientRT {
public Integer res_nclient_room_type_id;
public String res_sclient_rt_desc;
public String res_sclient_rt_name;
public String res_sclient_rt_code;
//getter and setter
...
}
PostgrSQL结果
您可以使用我在我的项目中使用过的可能适用于您的逻辑,也可以不使用。 我还没有将它与JPA对象映射一起使用。
public class ObjectSerializer {
private static ObjectMapper objectMapper;
@Autowired
public ObjectSerializer(ObjectMapper objectMapper) {
ObjectSerializer.objectMapper = objectMapper;
}
public static <T> T getObject(Object obj, Class<T> class1) {
String jsonObj = "";
T userDto = null;
try {
jsonObj = objectMapper.writeValueAsString(obj);
userDto = (T) objectMapper.readValue(jsonObj, class1);
System.out.println(jsonObj);
} catch (JsonProcessingException jpe) {
} catch (IOException e) {
e.printStackTrace();
}
return userDto;
}
}
希望这会有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.