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>