hibernate 配置
来源:互联网 发布:电话聊天软件 编辑:程序博客网 时间:2024/06/08 05:27
hibernate jar 包引入 :maven为例:
<!--hibernate-core --><dependency><groupId>org.hibernate</groupId><artifactId>hibernate-core</artifactId><version>5.2.10.Final</version></dependency>
User.hbm.xml 配置文件:
class 为 model 包名 table 为数据库表名id 为数据库主键<hibernate-mapping> <class name="com.ittx.usermanager.model.User" table="user"> <id name="id" type="int"> <column name="id" /> <generator class="native" /> </id> <property name="name" type="string"> <column name="name" /> </property> <property name="age" type="int"> <column name="age" /> </property> <property name="sex" type="int"> <column name="sex" /> </property> <property name="headerUri" type="string"> <column name="headuri" /> </property> </class></hibernate-mapping>
hibernate 连接配置文件
<hibernate-configuration><session-factory><!-- 设置数据库驱动 --><property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property><!-- 设置数据库URL --><property name="hibernate.connection.url">jdbc:mysql://localhost:3306/usermanager?characterEncoding=utf8</property><!-- 数据库用户名 --><property name="hibernate.connection.username">root</property><!-- 数据库密码 --><property name="hibernate.connection.password">123</property><!-- 指定对应数据库的方言,hibernate为了更好适配各种关系数据库,针对每种数据库都指定了一个方言dialect --><property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property><!-- 指定ddl的生成方式 --><property name="hibernate.hbm2ddl.auto">update</property><!-- 输出sql语句 --><property name="hibernate.show_sql">true</property><!-- 格式化输出sql语句 --><property name="hibernate.format_sql">true</property><property name="hibernate.current_session_context_class">thread</property><!-- 加载映射文件 --><mapping resource="com/ittx/usermanager/model/User.hbm.xml" /></session-factory></hibernate-configuration>
阅读全文
0 0
- hibernate-hibernate的配置
- 【Hibernate】2.Hibernate配置
- Hibernate 配置!
- Hibernate配置
- Hibernate配置
- Hibernate 配置
- Hibernate配置
- Hibernate配置
- Hibernate配置
- Hibernate配置
- hibernate 配置
- Hibernate 配置
- Hibernate 配置
- hibernate配置
- 配置HIbernate
- Hibernate 配置
- Hibernate配置
- Hibernate配置
- GPRS联网过程简介
- 微信小程序入门资料,学习资料汇总
- linux动态编译和静态编译
- js data 日期转换大全
- i2c、spi设备展开过程
- hibernate 配置
- C语言学习之链表
- OpenCV中不同格式图片的保存
- Nature:地球微生物组计划首发成果
- 一 蓝牙概述
- LTE:OFDM的原理
- c语言学习日记2:单字符输出,判断年份,累加
- redis的事务处理
- 关于算法