Hibernate(基础1)

一.hibernate框架职责
这里写图片描述
二.hibernate是orm框架
对象关系映射(英语:(Object Relational Mapping,简称ORM,或O/RM,或O/R mapping)
这里写图片描述
orm分为4级:
hibernate属于4级:完全面向对象操作数据库
mybatis属于2级
dbutils属于1级
三.hibernate框架搭建
1.导包
这里写图片描述
驱动包
这里写图片描述
2.创建数据库,准备表,实体
这里写图片描述
3.书写orm元数据(对象与表的映射配置文件)
实体

public class Customer {
    private Long cust_id;
    private String cust_name;
    private Long cust_user_id;
    private Long cust_create_id;
    private String cust_source;
    private String cust_industry;
    private String cust_level;
    private String cust_linkman;
    private String cust_phone;
    private String cust_mobile;
}

并生成get和set方法

导入约束
这里写图片描述

这里写图片描述
orm元数据Customer.hbm.xml文件书写

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC 
    "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
    <class name="hibernate.domain.Customer" table="cst_customer">
        <id name="" column=""></id>
        <property name="cust_id" column="cust_id"></property>
        <property name="cust_name" column="cust_name"></property>
        <property name="cust_user_id" column="cust_user_id"></property>
        <property name="cust_create_id" column="cust_create_id"></property>
        <property name="cust_source" column="cust_source"></property>
        <property name="cust_industry" column="cust_industry"></property>
        <property name="cust_level" column="cust_level"></property>
        <property name="cust_linkman" column="cust_linkman"></property>
        <property name="cust_phone" column="cust_phone"></property>
        <property name="cust_mobile" column="cust_mobile"></property>
    </class>
</hibernate-mapping>

4.书写主配置文件
约束同上导入,约束文件为hibernate-configuration-3.0.dtd

5.书写代码测试

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值