一. hibernate 配置需要 4 步 1. 配置 hibernate.cfg.基本的数据库连接, 还有一些其他的 比如: dialect, format_sql, show_sql, hbm2ddl.auto 等等. 2. 创建实体类. ...
一. hibernate 配置需要 4 步
1. 配置 hibernate.cfg.基本的数据库连接, 还有一些其他的 比如: dialect, format_sql, show_sql, hbm2ddl.auto 等等.
2. 创建实体类.
3. 创建实体类的映射文件,如: 若实体类是 News, 那么实体类映射文件就是: News.hbm.
4. 进行测试.
1. 配置 hibernate.cfg.
<hibernate-configuration> <session-factory> <!-- 配置 hibernate0 的基本信息 --> <property name="hibernate.connection.username">root</property> <property name="hibernate.connection.password">root</property> <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property> <property name="hibernate.connection.url">jdbc:mysql:///test</property> <!-- 配置 hibernate0 其他信息 --> <property name="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property> <property name="hibernate.format_sql">true</property> <property name="hibernate.show_sql">true</property> <property name="hibernate.hbm2ddl.auto">update</property> <!-- 映射到 News.hbm.--> <mapping resource="org/blanck/entities/News.hbm./> </session-factory></hibernate-configuration>
// 省略 get/set 方法如果数据库
原来是存在的,则不会出现上面的错误.
海外公司注册、海外银行开户、跨境平台代入驻、VAT、EPR等知识和在线办理:https://www.xlkjsw.com
原标题:Hibernate 基本配置 (脚手架)
关键词:Hibernate
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们:
admin#shaoqun.com
(#换成@)。