Hibernate:could not execute query 列名無效
java.sql.SQLException: 列名無效
最近換了個專案組,資料訪問層從使用Mybatis變為Hibernate,開發過程中也遇到一些小麻煩,比如我的XX.hbm.xml檔案中的sql打印出來執行查詢,是OK的。但是在專案中呼叫就會報錯 java.sql.SQLException: 列名無效,如下圖。
原因: 由於習慣了Mybatis自己寫SQL,在XX.hbm.xml檔案中,select 欄位寫少了,導致在對映類中,存在欄位A,而SQL查詢的結果集中卻沒有A欄位。
解決: select 儘量使用*號吧,查詢出全部欄位,不會報錯。不過相對效率會低。
隨便一提,
Mybatis和Hibernate使用感受比較:
Mybatis | Hibernate | |
---|---|---|
優點 | 1.SQL靈活,對於複雜查詢有良好的支援;2.使用簡潔 | 封裝了CRUD操作,對單表查詢有非常好的支援 |
缺點 | 需要開發者指定ResultMap | 一般情況下需要查詢全部欄位。不過可以使用HQL語句解決,或者使用DetachedCriteria高階查詢 |
相關推薦
Hibernate:could not execute query 列名無效
java.sql.SQLException: 列名無效 最近換了個專案組,資料訪問層從使用Mybatis變為Hibernate,開發過程中也遇到一些小麻煩,比如我的XX.hbm.xml檔案中的sql打印出來執行查詢,是OK的。但是在專案中呼叫就會報錯 java.sql.SQLExce
hibernate創建本地查詢後進行查詢的時候報錯: could not execute query;列名無效
遇到 註解 ransient 映射類 日誌信息 數據 字段 數據庫 get 今天在走數據下發的時候遇到了一個問題: 創建一個sql語句(sql語句很簡單) 創建了一個本地查詢,執行這個sql語句 結果報錯:could not execute query;列名無效 先檢查數據
Oracle:org.hibernate.exception.JDBCConnectionException: could not execute query
前段時間做省市區街道的匯入,用的Oracle資料庫,批量新增然後就時不時的報org.hibernate.exception.JDBCConnectionException: could not execute query這個錯,特別的鬱悶,程式碼沒有任何問
分析Hibernate:could not initialize proxy - no Session
異常: org.hibernate.LazyInitializationException: could not initialize proxy - no Session 在做一個專案的時候遇到了這個問題,大概的意思是不能 初始化,session 關閉了的,於是就想到可能是sess
解決Hibernate:could not initialize proxy
異常: org.hibernate.LazyInitializationException: could not initialize proxy - no Sessionat org.hibernate.proxy.AbstractLazyInitializer.init
android studio報錯:Could not execute build using Gradle installation
問題出現在更新到gradle1.8之後。 報錯資訊主要是 Could not execute build using Gradle installation '/Users/Admin/.gradle/wrap... 分析問題,不是配置的問題,因為之前gradle1.8還
SSH級聯操作報錯:org.hibernate.exception.ConstraintViolationException: Could not execute
SSH整合過程中,刪除具有外來鍵的記錄時報錯: spring4+hibernate4 org.hibernate.exception.ConstraintViolationException: C
org.hibernate.exception.GenericJDBCException: could not execute statement
intern err class sed urn ldr get protocol servlet 異常信息: Exception: org.hibernate.exception.GenericJDBCException: could not execute statem
HTTP Status 500 - Request processing failed; nested exception is org.hibernate.exception.GenericJDBCException: could not execute statement
resolve tac enc session stand cep exe intra abstract 1.什麽操作出現:當我在項目中添加產品或者修改時,瀏覽器出現HTTP Status 500 - Request processing failed; nested ex
hibernate原生sql封裝,報錯信息:could not find setter for rownum_
not .com 解決 做了 hiberna could 解決方法 ber bsp 今天用hibernate的時候,用了一個原生態sql做了一個分頁查詢,結果就報錯了。。。 找到解決方法了:http://shmily2038.iteye.com/blog/17049
數據庫異常整理:org.hibernate.QueryException: could not resolve property: “mStation”
blog use could not 小寫字母 www. 實例變量 特殊情況 lips 數據 最近用hibernate作數據庫查詢,結果遇到問題: org.hibernate.QueryException: could not resolve property: ‘mSta
hibernate save資料到 oracle問題之二:could not extract ResultSet
接上一條,又出一問題,報錯: “could not extract ResultSet; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not extrac
spring hibernate整合: Could not obtain transaction-synchronized Session for current thread
當hibernate 將事務交由 spring管理時, 應將 @Transactional 加入對接的介面層,即其它物件呼叫的方法上,若將@Transactional加在內部方法上,將會出現 Could not obtain transacti
使用SSH Hibernate自動建立表的問題:Could not parse mapping document from input stream
在我們開始學習Hibernate的時候,我們找到Hibernate可以幫助我們自動建立資料庫表,但前提是我們必須配置這個屬性:<property name="hbm2ddl.auto">u
轉:Could not commit Hibernate 問題,spring 事物 提交前session關閉問題
org.springframework.transaction.TransactionSystemException: Could not commit Hibernate transaction; nested exception is org.hibernate.Tra
[已解決]org.hibernate.exception.SQLGrammarException: could not execute statement
第一次寫問題記錄,在網上找了許久但還沒解決 <property name="hibernate.hbm2ddl.auto">update</property> 設定成update,應該是會自動生成表。但是它卻沒生成。 下面是各個檔案的程式碼: &
hibernate查詢語句卻報Could not execute JDBC batch update錯誤的原因追蹤
業務系統在使用hibernate的list方法做查詢時報了以下的一個錯誤: org.hibernate.exception.DataException: Could not execute JDBC batch update,非常奇怪,我們當前的方法中並沒有做
小談Hibernate下SQL Grammer Exception,Could not execute JDBC batch update異常的解決
[insert into XT_JYSHQ (ZQJC, ZSP, JKP, ZGJ, ZDJ, YJLX, SPJ, CJL, CJJE, JYRQ, ZQDM) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)]; nested exception is java.sql.
hibernate 刪除表異常 DataIntegrityViolationException: Could not execute JDBC batch update
最近在做專案中, hibernate 物理刪除 delete 方法的時候, 爆了詭異的錯誤, 比如 org.spr
ssh報錯:Could not load host key:/etc/ssh/ssh_host_rsa_key&ssh_host_ecdsa_key&ssh_host_ed25519_key
ssh報錯:could not load host key今天ssh遠程的時候發現無法遠程,登錄主機查看ssh服務狀態,報錯如下去查看秘鑰發現文件大小為0,看起來是生成秘鑰失敗了才導致的故障,解決方法簡單,刪除原有的秘鑰,重新生成秘鑰就OK了然後重啟ssh服務,自動生成新的秘鑰就可以了或者也可以通過命令行重新