[TOC]
# 下載Hibernate5
https://sourceforge.net/projects/hibernate/files/hibernate-orm/5.0.7.Final/
解壓完后,目錄結構如下


包含的都是必要的jar包
# 引入Hibernate包

# 準備表
~~~
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;
~~~
在項目src下,創建domain包,并在包下創建實體類Customer(對應數據庫cst_customer),Customer類包含與cst_customer數據表字段對應的屬性,已經setXX,getXX方法
~~~
package domain;
public class Customer {
private Long cust_id;
private String cust_name;
private String cust_source;
private String cust_industry;
private String cust_level;
private String cust_phone;
private String cust_mobile;
public Long getCust_id() {
return cust_id;
}
public void setCust_id(Long cust_id) {
this.cust_id = cust_id;
}
public String getCust_name() {
return cust_name;
}
public void setCust_name(String cust_name) {
this.cust_name = cust_name;
}
public String getCust_source() {
return cust_source;
}
public void setCust_source(String cust_source) {
this.cust_source = cust_source;
}
public String getCust_industry() {
return cust_industry;
}
public void setCust_industry(String cust_industry) {
this.cust_industry = cust_industry;
}
public String getCust_level() {
return cust_level;
}
public void setCust_level(String cust_level) {
this.cust_level = cust_level;
}
public String getCust_phone() {
return cust_phone;
}
public void setCust_phone(String cust_phone) {
this.cust_phone = cust_phone;
}
public String getCust_mobile() {
return cust_mobile;
}
public void setCust_mobile(String cust_mobile) {
this.cust_mobile = cust_mobile;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((cust_id == null) ? 0 : cust_id.hashCode());
result = prime * result + ((cust_industry == null) ? 0 : cust_industry.hashCode());
result = prime * result + ((cust_level == null) ? 0 : cust_level.hashCode());
result = prime * result + ((cust_mobile == null) ? 0 : cust_mobile.hashCode());
result = prime * result + ((cust_name == null) ? 0 : cust_name.hashCode());
result = prime * result + ((cust_phone == null) ? 0 : cust_phone.hashCode());
result = prime * result + ((cust_source == null) ? 0 : cust_source.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Customer other = (Customer) obj;
if (cust_id == null) {
if (other.cust_id != null)
return false;
} else if (!cust_id.equals(other.cust_id))
return false;
if (cust_industry == null) {
if (other.cust_industry != null)
return false;
} else if (!cust_industry.equals(other.cust_industry))
return false;
if (cust_level == null) {
if (other.cust_level != null)
return false;
} else if (!cust_level.equals(other.cust_level))
return false;
if (cust_mobile == null) {
if (other.cust_mobile != null)
return false;
} else if (!cust_mobile.equals(other.cust_mobile))
return false;
if (cust_name == null) {
if (other.cust_name != null)
return false;
} else if (!cust_name.equals(other.cust_name))
return false;
if (cust_phone == null) {
if (other.cust_phone != null)
return false;
} else if (!cust_phone.equals(other.cust_phone))
return false;
if (cust_source == null) {
if (other.cust_source != null)
return false;
} else if (!cust_source.equals(other.cust_source))
return false;
return true;
}
@Override
public String toString() {
return "Customer [cust_id=" + cust_id + ", cust_name=" + cust_name + ", cust_source=" + cust_source
+ ", cust_industry=" + cust_industry + ", cust_level=" + cust_level + ", cust_phone=" + cust_phone
+ ", cust_mobile=" + cust_mobile + "]";
}
}
~~~
- 基礎
- 編譯和安裝
- scanner類(鍵盤錄入)
- Random類(隨機數)
- 數組
- 方法
- 類
- ArrayList集合
- char與int
- eclipse
- IDEA
- 變量與常量
- 常用API
- String,StringBuffer,StringBuilder
- 正則,Date,DateFormat,Calendar
- 包裝類,System,Math,Arrays,BigInteger,BigDecimal
- 集合,迭代器,增強for,泛型
- List,set,判斷集合唯一
- map,Entry,HashMap,Collections
- 異常
- IO
- File
- 遞歸
- 字節流
- 字符流
- IO流分類
- 轉換流
- 緩沖流
- 流的操作規律
- properties
- 序列化流與反序列化流
- 打印流
- commons-IO
- IO流總結
- 多線程
- 線程池
- 線程安全
- 線程同步
- 死鎖
- lock接口
- ThreadLoad
- 等待喚醒機制
- 線程狀態
- jdbc
- DBUtils
- 連接池DBCP
- c3p0連接池
- 網絡編程
- 多線程socket上傳圖片
- 反射
- xml
- 設計模式
- 裝飾器模式
- web service
- tomcat
- Servlet
- response
- request
- session和cookie
- JSP
- EL
- JSTL
- 事務
- 監聽器Listener
- 過濾器Filter
- json
- linux安裝軟件
- 反射詳解
- 類加載器和注解
- 動態代理
- jedis
- Hibernate
- 簡介
- 創建映射文件
- Hibernate核心配置文件
- 事務和增刪改查
- HibernateUtils
- 持久化對象的三種狀態
- 檢索方式
- query
- Criteria
- SQLQuery
- 持久化類
- 主鍵生成策略
- 緩存
- 事務管理
- 關系映射
- 注解
- 優化
- struts2
- 搭建
- 配置詳解
- Action
- 結果跳轉方式
- 訪問ServletAPI方式
- 如何獲得參數
- OGNL表達式
- valueStack 值棧
- Interceptor攔截器
- spring
- 導包
- IOC和DI
- Bean獲取與實例化
- Bean屬性注入
- spring注解
- 注解分層
- junit整合
- aop
- 動態代理實現
- cglib代理實現
- aop名詞
- spring的aop
- aop-xml詳解
- aop-注解詳解
- 代理方式選擇
- jdbcTemplate
- spring事務管理
- 回滾注意
- 事務傳播屬性
- MyBatis
- MyBatis簡介
- 入門程序
- 與jdbc hibernate不同
- 原始Dao開發
- Mapper動態代理方式
- SqlMapConfig.xml配置文件
- 輸入參數pojo包裝類
- resultMap
- 動態sql
- 一對一關聯
- 一對多
- 整合spring
- 逆向工程
- maven
- maven簡介
- 倉庫
- maven目錄結構
- maven常用命令
- 生命周期
- eclipse中maven插件
- 入門程序
- 整合struct
- 依賴范圍
- 添加插件
- idea配置
- jar包沖突
- 分模塊開發
- 構建可執行的jar包(包含依賴jar包)
- springMVC
- 處理流程
- java面試
- java版本升級
- java1-8版本變更
- java9新特性
- 鎖
- java資料
- idea
- jdk版本切換
- log4j
- 入門實例
- 基本使用方法
- Web中使用Log4j
- spring中使用log4j
- java代碼優化