gpt4 book ai didi

java.lang.ClassCastException : sametype cannot be cast to sametype

转载 作者:行者123 更新时间:2023-12-01 14:24:54 30 4
gpt4 key购买 nike

非常奇怪的异常

我的代码

 Query q = em.createQuery("SELECT  u FROM Chatuser u");

List<Chatuser> list = (List<Chatuser>) q.getResultList();
for (int i = 0; i < list.size(); i++) {
Object aa = list.get(i);
Chatuser chatuser = (Chatuser)aa;

异常

   ex = (java.lang.ClassCastException) java.lang.ClassCastException: Entities.service.Chatuser cannot be cast to Entities.service.Chatuser

问题是什么?

最佳答案

这篇文章可能也回答了您的问题
Java, getting class cast exception where both classes are exactly the same

类加载器冲突可能会出现问题

关于java.lang.ClassCastException : sametype cannot be cast to sametype,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17231535/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com