我們hebernate的主要配置檔案就是
(映射檔案)類名.hbm.xml
<hibernate-mapping>
<class name="我們建立的實體類" table="我們建立的表名字">
指定類與表的定義,指定那個屬性與主鍵對應。
<id name="屬性名字" column="表中的列">
<generator class="increment"> //指定主鍵的生成政策,單線程,因為自增的情況。
</id>
映射簡單類型屬性(8種基本資料類型及其相應的包裝類類型,String,日期)
<property name="" column=""/>
<property name="" column=""/>
<property name="" column=""/>
</hibernate-mapping>
(配置檔案)hibernate.cfg.xml
<hibernate-configuration>
<session-factory>
資料庫連接配接設定
<property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="connection.url">jdbc:oracle:thin:@127.0.0.1:1521:orcl</property>
<property name="connection.username">system</property>
<property name="connection.password">Admin123456</property>
sql dialect
<property name="dialect">org.hibernate.dialect.Oracle10gDialect</property>
sql show
<property name="show_sql">true</property>
導入外部映射檔案
<mapping resource="檔案url"/>
</hibernate-configuration>