Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/hibernate/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring boot 错误-已处理新的全局异常!Message=java.util.LinkedHashMap无法转换为java.math.BigInteger_Spring Boot_Hibernate_Spring Data Jpa_Hql_Jpql - Fatal编程技术网

Spring boot 错误-已处理新的全局异常!Message=java.util.LinkedHashMap无法转换为java.math.BigInteger

Spring boot 错误-已处理新的全局异常!Message=java.util.LinkedHashMap无法转换为java.math.BigInteger,spring-boot,hibernate,spring-data-jpa,hql,jpql,Spring Boot,Hibernate,Spring Data Jpa,Hql,Jpql,patientId的数据类型是实体对象中的BigInteger private BigInteger patientId; 代码: 正如在注释中所说,不能将字符串列表作为数字字段的参数传递 您应该将参数声明为 public List<ChatRoomHistory> getLastChatDetails(List<BigInteger> patientIds) public List getLastChatDetails(List patientIds) 您可以通过以

patientId的数据类型是实体对象中的BigInteger

private BigInteger patientId;
代码:


正如在注释中所说,不能将字符串列表作为数字字段的参数传递

您应该将参数声明为

public List<ChatRoomHistory> getLastChatDetails(List<BigInteger> patientIds)
public List getLastChatDetails(List patientIds)

您可以通过以下方式更正您的方法:

@Override
public List<ChatRoomHistory> getLastChatDetails(List<BigInteger> patientIds)
{
    String hql = "select c from ChatRoomHistory c where c.type = 'NO' and c.patientId in :patientIds ORDER BY c.chatCloseTime DESC";
    TypedQuery<ChatRoomHistory> query = sessionFactory.getCurrentSession().createQuery(hql, ChatRoomHistory.class);
    query.setParameter("patientIds", patientIds);
    return query.getResultList();
}
@覆盖
公共列表getLastChatDetails(列表)
{
String hql=“从聊天室历史记录中选择c,其中c.type='NO'和c.patientId in:patientIds ORDER BY c.chatCloseTime DESC”;
TypedQuery query=sessionFactory.getCurrentSession().createQuery(hql,ChatRoomHistory.class);
setParameter(“patientIds”,patientIds);
返回query.getResultList();
}
评论:

  • 即使HQL不要求存在
    select_子句
    ,它也需要包含一个

  • 值列表不能为空;它必须至少包含一个值。(见附件)


  • 您正在为
    patientIds
    发送
    List
    无效我想,您应该发送
    List
    我也尝试过使用BigInteger,但出现错误-新的全局异常已处理!Message=java.util.LinkedHashMap无法强制转换为java.math.BigInteger java.lang.ClassCastException:java.util.LinkedHashMap无法强制转换为java.math.BigInteger我尝试了相同的方法,但获取:错误-已处理新的全局异常!Message=java.util.LinkedHashMap不能转换为java.math.BigInteger java.lang.ClassCastException:java.util.LinkedHashMap不能转换为java.math.BigInteger可以显示整个代码吗?是否在某个地方声明LinkedHashMap?List patientIds=mapper.readValue(mapper.writeValueAsString(thpResponse.getResponseData()),List.class); List chatRoomHistory=chatHistoryDAO.getLastChatDetails(patientIds)@这意味着json中存在问题,您的ID位于
    managedAccountsUserIds
    节点中。您可以先在查询中传递一些常量id来检查您的查询是否工作。@Ramanuj请参见此处详细信息列表不是空的:但GetSign o-8080-exec-2:]c.t.c.u.e.GlobalExceptionHandler.handleException:243错误-已处理新的全局异常!Message=java.util.LinkedHashMap不能转换为java.math.BigInteger java.lang.ClassCastException:java.util.LinkedHashMap不能转换为org.hibernate.type.descriptor.java.BigIntegerTypeDescriptor.unwrap(BigIntegerTypeDescriptor.java:19)上的java.util.LinkedHashMap不能转换为java.BigInteger此堆栈跟踪是否与方法
    getLastChatDetails
    执行有关?
    public List<ChatRoomHistory> getLastChatDetails(List<BigInteger> patientIds)
    
    @Override
    public List<ChatRoomHistory> getLastChatDetails(List<BigInteger> patientIds)
    {
        String hql = "select c from ChatRoomHistory c where c.type = 'NO' and c.patientId in :patientIds ORDER BY c.chatCloseTime DESC";
        TypedQuery<ChatRoomHistory> query = sessionFactory.getCurrentSession().createQuery(hql, ChatRoomHistory.class);
        query.setParameter("patientIds", patientIds);
        return query.getResultList();
    }