org.hibernate.hql.internal.ast.QuerySyntaxException: expecting OPEN, found 'from' near line 1, colum
程式碼如下:
package cn.com.query; import java.util.List; import org.hibernate.Query; import org.hibernate.Session; import org.hibernate.Transaction; import org.junit.Test; import cn.com.dao.User; import cn.com.util.Hibernate_Utils; public class Demo1 { /* * author:命運的信徒 date:2018/12/05 arm:完成CRM的客戶的條件查詢 */ @Test public void demo() { //統計索引查詢 Session session=Hibernate_Utils.openSession(); Transaction tx=session.beginTransaction(); Query q=session.createQuery("select count from User"); //對於查詢結果的只有一種,可以採取以下方法 Long i=(Long) q.uniqueResult(); System.out.println(i); tx.commit(); session.close(); } }
原因:
HQL語法錯誤;count是關鍵字,
應該是
Query q=session.createQuery("select count(*) from User");
相關推薦
org.hibernate.hql.internal.ast.QuerySyntaxException: expecting OPEN, found 39;from39; near line 1, colum
程式碼如下: package cn.com.query; import java.util.List; import org.hibernate.Query; import org.hibernate.Session; import org.hibernate.Transaction; i
org.hibernate.hql.internal.ast.QuerySyntaxException: Base is not mapped [from Base]
Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: Base is not mapped org.hibernate.hql.internal.ast.QuerySyntaxException: Base is not
org.hibernate.hql.internal.ast.QuerySyntaxException: USER is not mapped 報錯解決
錯誤日誌: org.hibernate.hql.internal.ast.QuerySyntaxException: USER is not mapped [FROM USER] at org.hibernate.hql.internal.ast.QuerySyntaxEx
Hibernate查詢報錯:org.hibernate.hql.internal.ast.QuerySyntaxException: XXX is not mapped
這個錯誤的產生原因是,hibernate執行查詢的語句hql是面向物件的查詢,而不是面向資料庫表的查詢,因此在hql語句中的物件名必須與實體類的類名一致,嚴格區分大小寫。 如實體類為 Car,則hql
SSH執行hql報錯:Caused by: org.hibernate.hql.ast.QuerySyntaxException: user is not mapped [from user where username = ?]
執行 occurred ble xml文件 ron red 報錯 temp caused 報錯信息: ERROR Dispatcher:38 - Exception occurred during processing request: user is not mapped
org.hibernate.hql.ast.QuerySyntaxException: User is not mapped [from User] 異常總結
異常如下:org.hibernate.hql.ast.QuerySyntaxException: User is not mapped [from User] at org.hibernate.hql.ast.util.SessionFactoryHelper.requi
每日一得-org.hibernate.hql.ast.QuerySyntaxException: Path expected for join!錯誤解決辦法
org.hibernate.hql.ast.QuerySyntaxException: Path expected for join! HQL進行JOIN連線查詢時需要注意幾點: 1.HQL不支援ON,需要將ON換成WHERE 2.需要註明物件之間的對映關係 Produc
SSH報錯:org.hibernate.hql.ast.QuerySyntaxException: User is not mapped [select o from User o where 1=1
Struts has detected an unhandled exception: Messages: 1.User is not mapped [select o from User o where 1=1 order by o.id asc] 2.User is not mapped [select
HQL子查詢報錯:org.hibernate.hql.ast.QuerySyntaxException: unexpected token...
HQL語句: selectcount(*) from (select stu.classId from Student stu groupby stu.classId) t_tmp_count 執行
No data type for node: org.hibernate.hql.ast.tree.IdentNode問題的解決
使用Hibernate的時候,出現這個錯誤資訊,經過網上的解決方法,成功的解決這個錯誤資訊,並且記錄下來。 從錯誤資訊,可以看出是因為在執行hql語句的時候,hql中填寫的欄位沒有和實體類中的欄位對應,但是我檢視自己的實體類中的屬性的名稱和屬性對於
Hibernate HQL的條件中如果in包含太多的引數會導致堆疊溢位StackOverflowError、org.hibernate.hql.ast.util.NodeTraverser.visit
轉自:http://www.bitiliu.com/archives/43 異常情況 java.lang.StackOverflowError at rg.hibernate.hql.ast.QueryTranslatorImpl$JavaConstant
weblogic10異常:org.hibernate.QueryException: ClassNotFoundException: org.hibernate.hql.ast.
GOOGLE上找到解決方法,記錄與些,本人採用的方法三. 原因: Hibernate3.0 採用新的基於ANTLR的HQL/SQL查詢翻譯器,在Hibernate的配置檔案中,hibernate.query.factory_class屬性用來選擇查詢翻譯器。 (1)選擇Hibernate3.0的查詢翻譯
weblogic 下異常 org.hibernate.QueryException: ClassNotFoundException: org.hibernate.hql.ast.HqlToken
專案之前在 Tomcat 環境下一直都正常執行,今天應客戶要求需要遷移到 webLogic 10.3.6 下, 部署後竟然丟擲了 org.hibernate.QueryException: ClassNotFoundException: org.hibernate.
Caused by: java.lang.NoClassDefFoundError: org/hibernate/validator/internal/engine/DefaultParameterN
Caused by: java.lang.NoClassDefFoundError: org/hibernate/validator/internal/engine/DefaultParameterNameProvider at org.hibernate.validator.inter
org hibernate validator internal engine ConfigurationImpl ge
default set gin ice dac registry creating eva kth 1、錯誤描述 嚴重: StandardWrapper.Throwable org.springframework.beans.factory.BeanCreationE
ERROR [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] - Data truncation: Incorrect datetime value: 39;39; for column 39;pubdate39; at row 1
jdk red ssi rate orb authent ans read nat 之前的Connector/J版本是:mysql-connector-java-5.0.4-bin.jar 後來換成mysql-connector-java-5.1.45-bin.ja
json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 1 column 2 (ch
今天在使用字串解析成json物件時,遇到了下面的錯誤: json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 1 column 2 (char 1)
Could not open Hibernate Session for transaction; nested exception is org.hibernate.TransactionExcep linux下mysql修改連接超時wait_timeout修改後就ok了
有用 linux下 net ans ack delayed 線上 nec 宋體 Linux下mysql修改連接超時wait_timeout 1,首先: show variables like ‘%timeout%‘; 顯示結果: +--------
Hibernate4 使用Proxool連線資料庫出現 at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcSer
其實只要看第一行就可以了 at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:244) ,就是在配置的時候沒取到值。那麼為什麼沒取到值呢,是因為Hiber
ssh專案報錯:ERROR org.hibernate.internal.SessionImpl - HHH000346: Error during managed flush [Batch upda
遇到進行saveOrUpdate的時候新增資料hibernate報錯 ERROR org.hibernate.internal.SessionImpl - HHH000346: Error during managed flush [Batch update returne