hibernate学习笔记1

  //读取ibernate.cfg.xml
        Configuration cfg = new Configuration().configure();
        //创建 SchemaExport
        SchemaExport export = new SchemaExport(cfg);
        export.create(true, true);

 

hibernate.cfg.xml

<hibernate-configuration>
    <session-factory>
        <property name="hibernate.connection.url">jdbc:mysql://127.0.0.1/hibernate_first</property>
        <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
        <property name="hibernate.connection.username">root</property>
        <property name="hibernate.connection.password">best</property>
        <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
        <property name="hibernate.show_sql">true</property>
        <mapping resource="com/yu/model/User.hbm.xml"/>
    </session-factory>
</hibernate-configuration>

映射配置

<hibernate-mapping >

    <class name="com.yu.model.User">
        <id name="id">
            <generator class="uuid"/>
        </id>
        <property name="name"/>
        <property name="password"/>
        <property name="createTime"/>
        <property name="expireTime"/>
    </class>
    
    
</hibernate-mapping>

posted on 2013-07-31 09:35  鱼东鱼  阅读(142)  评论(0编辑  收藏  举报

导航