原因: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时,它也不起作用。如何将其从字符串转换为整数?
相关文章