hibernate入門

來源:互聯網
上載者:User

標籤:io   sp   for   檔案   資料   on   cti   bs   as   

***********

1,hibernate.hbm.xml,

表與對象的映射規律

2,hibernate.cfg.xml

hibernate的設定檔

比如還有那些其他資源檔,在什麼地方

hibernate將要映射成那種資料庫的語言

hibernate.dialect=org.hibernate.dialect.MySQLDialect
hibernate.hbm2ddl.auto=update <!--是否需要根據映射來源資料生產資料表結構 -->
hibernate.show_sql=true
hibernate.format_sql=false

註:

hibernate.hbm2ddl.auto可以取值:

create-drop:每次建立,關閉時刪除

create:每次建立前刪除,關閉時不刪除(測試時方便)

update:每次發現有不同,則更新

validate:每次發現有不同,不會更新,而是報錯,所以更安全

 

串連資料庫的資訊,如驅動名,url,username,password

3,hibernate預設把自動認可事務關閉了

所以要顯式提交

tx=s.beginTransaction()

tx.commit();

4,mysql預設的engine=myisam

不支援事務,不能復原

而InnoDB支援事務,可以復原

5,

 

 

 

***********

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.