本文介紹了原因:org.hibernate.QueryException:無法解析CAST:INT的請求類型的處理方法,對大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!
問題描述
原因:org.hibernate.QueryException:無法解析請求
轉(zhuǎn)換類型: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查詢:
公共滾動(dòng)結(jié)果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;
}
當(dāng)我嘗試強(qiáng)制轉(zhuǎn)換為int時(shí),它也不起作用。如何將其從字符串轉(zhuǎn)換為整數(shù)?
這篇關(guān)于原因:org.hibernate.QueryException:無法解析CAST:INT的請求類型的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,