写一个Hibernate程序的步骤:
1.导入相关jar包。
2.创建持久化类。
3.创建映射文件。 
 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <!DOCTYPE hibernate-mapping PUBLIC 
 3     "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
 4     "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
 5 <hibernate-mapping package="com.lei.pojo">
 6     <class name="User" table="t_user">
 7         
 8         <id name="id" column="id">
 9             <generator class="native"/>
10         </id>
11         
12         <property name="username" column="username"/>
13         <property name="password"/>
14         
15     </class>
16 </hibernate-mapping> 
4.创建Hibernate配置文件。
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
    "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
    "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"
>
<hibernate-configuration>

    <session-factory>
        
        <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
        <property name="hibernate.connection.url">jdbc:mysql:///lei</property>
        <property name="hibernate.connection.username">root</property>
        <property name="hibernate.connection.password">root</property>
    
        <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
        
        <property name="hibernate.c3p0.max_size">10</property>
        <property name="hibernate.c3p0.min_size">2</property>
        <property name="hibernate.c3p0.timeout">5000</property>
        <property name="hibernate.c3p0.max_statements">100</property>
        <property name="hibernate.c3p0.idle_test_period">3000</property>
        <property name="hibernate.c3p0.acquire_increment">2</property>
        <property name="hibernate.c3p0.validate">false</property>
        
        <property name="current_session_context_class">thread</property>
        
        <property name="show_sql">true</property>
        
        <mapping resource="com/lei/pojo/user.hbm.xml"/>
    
    </session-factory>


</hibernate-configuration>
5.测试运行。