[Ljava.lang.Object;无法转换为 com.lglsys.entity.EntityName

[Ljava.lang.Object; cannot be cast to com.lglsys.entity.EntityName

我试图从数据库中获取特定数据,但每次都出现以下错误!

java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to com.lglsys.entity.TDasProductDownload

所以这是我的查询服务class

@Dependent
public class QueryService {
     List<TDasProductDownload> downloadLink = new ArrayList();
     final private Logger logger =
LogManager.getLogger(QueryService.class.getName());
    @PersistenceContext(unitName="DownloadServices")
    EntityManager em;

    public QueryService() { super(); }

public List<TDasProductDownload> findAllDownloadLinks() {
        try {
    downloadLink= 
    em.createQuery(queryForDownloadLinks,TDasProductDownload.class)
    .getResultList();
            return downloadLink;
        } catch (Exception e) {
            logger.info(e.toString());
            return null;
        }
    }   
}


程序在此class/中给出错误 端点 class

public class PreControlWSEndPoint {

    private Session session;
    final private Logger logger = LogManager.getLogger(PreControlWSEndPoint.class.getName());
    List<TDasProductDownload> downloadLink = new ArrayList();

    @PersistenceContext(unitName="DownloadServices")
    EntityManager em;

    @Inject
    QueryService service;

    @OnOpen
    public void Open(Session session) throws IOException, InterruptedException {
        this.session = session;
        this.sendMessage("Connection Oppened");
        logger.info("EndPoint Opened");

        try {
              downloadLink  =  service.findAllDownloadLinks();  
              logger.info(downloadLink.size());
              TDasProductDownload str = downloadLink.get(0);
              logger.info(str.getDownloadStatus()); //**Eror line!!**
        } catch (Exception e) {
            logger.info(e.toString() + " .D");
        }

    }
    @OnMessage
    public void onMessage(String message) {}
    @OnClose
    public void Close() {}
}

我看不到我的代码中发生了什么。

我修好了!

public List<String> findAllDownloadLinks() {
    try {
downloadLink= 
em.createQuery(queryForDownloadLinks,String.class)
.getResultList();
        return downloadLink;
    } catch (Exception e) {
        logger.info(e.toString());
        return null;
    }
} 

那我就可以这样打印了

for(int temp=0;temp<=downloadLink.size();temp++){
    logger.info(downloadLink.get(temp));
 }