面試題:談談你對hibernate的理解

來源:互聯網
上載者:User

標籤:content   hql   資訊   net   --   ssi   物件導向   問題   gravity   

說說這類問題一般要和一個東西比較。說說他們的長處和缺點,hibernate就和JDBC比較唄。你就說說JDBC的優缺點。然後說說hibernate的優缺點,最後對照得出hibernate更好。

hibernate:

   1、概念:ormapping    對象關係映射

       1、操作資料庫的架構

           底層是通過jdbc操作資料庫的

       2、用物件導向的方式操作資料庫

   2、jdbc的缺點

       1、代碼太繁瑣了

       2、不是物件導向的資料庫操作

       3、資源關閉的代碼也非常繁瑣,每次都得開啟、關閉

       4、沒有做到資料緩衝

       5、移植性比較差

       長處:

          由於是最低層的操作。所以效率比較高

   3、hibernate

       1、代碼比較精簡了

       2、是物件導向的資料庫操作

       3、僅僅須要關閉一個對象就能夠了session

       4、資料緩衝  一級緩衝  二級緩衝  查詢快取

       5、移植性比較好

       缺點:

          1、程式猿不能控制sql語句的產生

              hibernate中有一個hql

          2、假設一個項目對sql語句的最佳化要求特別高。不適合用hibernate

          3、假設一張表的資料量特別大。不適合用hibernate

對於查詢資料庫的sql最佳化問題。這裡有一個面試題,給你一個學生student表,叫你用各種方式查詢出指定的學生資訊

這裡有五種方式得出指定學生2,3,4的資訊

--方式一select *from studentwhere id in(2,3,4)--方式二select *from studentwhere id =2 or id=3 or id=4--方式三select *from studentwhere id between 2 and 4--方式四select *from studentwhere id>=2 and id<=4--方式五select *from studentwhere id=2unionselect *from studentwhere id=3unionselect *from studentwhere id=4


面試題:談談你對hibernate的理解

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.