原因:org.hibernate.QueryException:无法解析CAST:INT的请求类型

Caused by: org.hibernate.QueryException: Could not resolve requested type for CAST : INT(原因:org.hibernate.QueryException:无法解析CAST:INT的请求类型)

本文介绍了原因:org.hibernate.QueryException:无法解析CAST:INT的请求类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

原因:org.hibernate.QueryException:无法解析请求 转换类型:INT[SELECT SUBSTRING(ReferenceComtable,8,14)as SeqNum,SubbSTRING(ReferenceComtable,4,7)as Year Cegid, 子分类(ReferenceComtable,1,3)作为日记帐来源 Com.dso.model.comptabilite.cegid.EtapeJudiciaireLnkFactureActesHonoraires 其中,日期CegidGenerated Better:Date和:DateYearIntervalDate ORDER BY CAST(SeqNum AS INT)、CAST(Year Cegid AS INT)、CAST(Journal AS Int)ASC]
HQL查询: 公共滚动结果retrieveSequenceNumberForCegidGenerated(){
        StringBuilder queryBuilder = new StringBuilder(" SELECT SUBSTRING(referenceComptable , 8, 14) AS seqNum, SUBSTRING(referenceComptable, 4,7) AS yearCegid, SUBSTRING(referenceComptable, 1,3) AS journal")
                            .append(" FROM EtapeJudiciaireLnkFactureActesHonoraires ")
                            .append(" WHERE dateCegidGenerated BETWEEN :date AND :dateYearIntervalDate ")
                            .append(" ORDER BY CAST(seqNum AS INT), CAST(yearCegid AS INT), CAST(journal AS INT) ASC ");

        Query query = getFilteredCurrentSession().createQuery(queryBuilder.toString());

        //SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss");
        Date date = new Date();

        LocalDate yearIntervalDate = LocalDate.now().minusDays(365);
        Date dateYearIntervalDate = Date.from(yearIntervalDate.atStartOfDay(ZoneId.systemDefault()).toInstant());

        query.setParameter("date", date);
        query.setParameter("dateYearIntervalDate", dateYearIntervalDate);

        ScrollableResults referenceComptable = query.scroll(ScrollMode.FORWARD_ONLY);
        query.setCacheMode(CacheMode.IGNORE)
             .setFetchSize(500);

        return referenceComptable;
    }

当我尝试强制转换为int时,它也不起作用。如何将其从字符串转换为整数?

这篇关于原因:org.hibernate.QueryException:无法解析CAST:INT的请求类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:原因:org.hibernate.QueryException:无法解析CAST:INT的请求类型

基础教程推荐