4.1 資料庫建立表
create table `cst_customer` (
`cust_id` bigint(32) not null auto_increment comment '客戶編號(主鍵)',
`cust_name` varchar(32) not null comment '客戶名稱(公司名稱)',
`cust_source` varchar(32) default null comment '客戶資訊**',
`cust_industry` varchar(32) default null comment '客戶所屬行業',
`cust_level` varchar(32) default null comment '客戶級別',
`cust_phone` varchar(64) default null comment '固定**',
`cust_mobile` varchar(16) default null comment '移動**',
primary key (`cust_id`)
) engine=innodb auto_increment=1 default charset=utf8;
4.2 建立實體public class customer
4.3 建立對映
對映需要通過xml的配置檔案來完成,這個配置檔案可以任意命名。盡量統一命名規範(類名.hbm.xml)
<?xml version="1.0" encoding="utf-8"?>
4.4建立hibernate核心配置檔案
hibernate的核心配置檔案的名稱:hibernate.cfg.xml
必須在src目錄下
<?xml version="1.0" encoding="utf-8"?>
com.mysql.jdbc.driver
jdbc:mysql:///hibernate_day01
root
abc org.hibernate.dialect.mysqldialect
true
true
update
org.hibernate.connection.c3p0connectionprovider
5 20
1203000
4.5 編寫測試**public class hibernatedemo1
}
Hibernate之初入門
hibernate基礎 首先解釋持久化 persistence 即把資料 如記憶體中的物件 儲存到可永久儲存的儲存裝置中 如磁碟 持久化的主要應用是將記憶體中的物件儲存在關係型的資料庫中,當然也可以儲存在磁碟檔案中 xml資料檔案中等等。從另乙個角度看hibernate是乙個 物件關係對映 框架,當...
spring入門 spring入門案例
扯淡完成 spring到底是個什麼東西,這個是我們先放一放,首先,spring是乙個可以把我們的物件自動例項化的乙個框架,我們今天先演示下這個。我們知道,在我們程式執行的過程中,所有的 最後執行完都會在記憶體中有體現的。比如說,我寫了如下 public class user public strin...
Hibernate入門案例 第五步 實現新增操作
hibernate入門案例 第一步 搭建hibernate環境 hibernate入門案例 第二步 第二步,建立實體類和表 hibernate入門案例 第三步 配置實體類和資料庫一一對應關係 對映關係 hibernate入門案例 第四步 建立hibernate的核心配置檔案 hibernate入門案...