第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

錯(cuò)誤 org.hibernate.exception.SQLGrammarException:

錯(cuò)誤 org.hibernate.exception.SQLGrammarException:

紅顏莎娜 2022-06-04 11:03:05
我有我正在執(zhí)行的 hql 查詢,但收到一個(gè)我不太了解原因的錯(cuò)誤。這是我的代碼:@Overridepublic List<StaffRequest> getStaffLeaveRequest(String userID, Date startDate, Date endDate) {    Session currentSession = sessionFactory.getCurrentSession();            List<StaffRequest> results =     currentSession.createQuery("select new com.timesheet_Webservice.CustomEntity.StaffRequest(lr.leave_ID, lr.leave_Employee, concat(s.staff_First_Name, ' ', s.staff_Last_Name), "            + "(lr.leave_Days*8.5), lr.leave_Comments, '1805', concat(pro.project_Pastel_Prefix, ' - ', pro.project_Description), lr.leave_Start, lr.leave_End, lr.leave_IsApproved, "            + "(select lt.leaveType_Description from LeaveType lt where lt.leaveType_ID = lr.leave_Type)) "            + "from Staff s, Project pro, Leave lr "            + "where lr.leave_Employee = s.staff_Code and pro.project_Code = 1805 and lr.leave_Approved = :userID and lr.leave_IsApproved = 0 and s.staff_IsEmployee <> 0 "            + "and lr.leave_Start between :startDate and :endDate "            + "order by concat(s.staff_First_Name, ' ', s.staff_Last_Name)")            .setParameter("userID",userID).setParameter("startDate", startDate).setParameter("endDate", endDate).getResultList();       return results;}嘗試執(zhí)行時(shí),我在網(wǎng)頁(yè)上收到此錯(cuò)誤:org.hibernate.exception.SQLGrammarException:無(wú)法提取 ResultSet還有這個(gè)控制臺(tái)錯(cuò)誤:錯(cuò)誤:您的 SQL 語(yǔ)法有錯(cuò)誤;檢查與您的 MariaDB 服務(wù)器版本相對(duì)應(yīng)的手冊(cè),以在第 1 行的“離開 leave2_ where leave2_.Leave_Employee=staff0_.Staff_Code and project1_.Proj”附近使用正確的語(yǔ)法這似乎表明 where 子句有一些錯(cuò)誤,但我沒有看到任何特別錯(cuò)誤的地方。更新: 實(shí)體類項(xiàng)目@Entity@Table(name="project")public class Project {    @Id    @GeneratedValue(strategy=GenerationType.IDENTITY)    @Column(name="Project_Code")    public int project_Code;    @Column(name="Project_Customer")    public int project_Customer;    //A lot more attributes...}職員@Entity@Table(name="staff")public class Staff {    @Id    @Column(name="Staff_Code")    public String staff_Code;    ...}
查看完整描述

3 回答

?
守候你守候我

TA貢獻(xiàn)1802條經(jīng)驗(yàn) 獲得超10個(gè)贊

1)當(dāng)您使用java.util.DateforLeave.leave_Start時(shí),您應(yīng)該使用適當(dāng)?shù)?code>@Temporal值進(jìn)行注釋:

@Temporal(TemporalType.TIMESTAMP)
@Column(name="Leave_Start")
Date leave_Start;

2)設(shè)置查詢?nèi)掌趨?shù)時(shí),嘗試使用:

.setDate("startDate", startDate)

或者

.setParameter("startDate", startDate, TemporalType.TIMESTAMP)


查看完整回答
反對(duì) 回復(fù) 2022-06-04
?
慕村9548890

TA貢獻(xiàn)1884條經(jīng)驗(yàn) 獲得超4個(gè)贊

顯然,JPA 遵循變量名稱的一些規(guī)則或約定,不接受“_”,并且由于某種原因不接受中間大寫字母......它通過(guò)將所有變量更改為小寫字母對(duì)我有用



查看完整回答
反對(duì) 回復(fù) 2022-06-04
?
慕碼人2483693

TA貢獻(xiàn)1860條經(jīng)驗(yàn) 獲得超9個(gè)贊

好的,經(jīng)過(guò)多次測(cè)試,我發(fā)現(xiàn)了錯(cuò)誤的原因。由于某些未知原因,查詢似乎與引用表“離開”的名稱有問(wèn)題,并且每當(dāng)我嘗試從中檢索數(shù)據(jù)時(shí)都會(huì)產(chǎn)生錯(cuò)誤。但是,如果我將表重命名為“l(fā)eaves”之類的簡(jiǎn)單名稱,則查詢將成功執(zhí)行。任何人都可能知道這是為什么?



查看完整回答
反對(duì) 回復(fù) 2022-06-04
  • 3 回答
  • 0 關(guān)注
  • 157 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)