http://blog.sina.com.cn/s/blog_a7b8ab2801014m0e.html

hibernate.cfg.xml配置文件格式

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
 "-//Hibernate/Hibernate Configuration DTD
3.0//EN"
 "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
<session-factory>
 <property
name="connection.driver_class">
  com.mysql.jdbc.Driver
 </property>
 <property
name="connection.url">
  jdbc:mysql://localhost:3306/dang?useUnicode=true&amp;characterEncoding=utf8

</property>
 <property
name="connection.username">root</property>

<property
name="connection.password">123</property>

<!-- 显示SQL语句
-->
 <property
name="show_sql">true</property>

<property
name="format_sql">true</property>

<!-- 定义方言 -->
 <property
name="dialect">
  org.hibernate.dialect.MySQLDialect

</property>
  
<mapping 
resource="entity/User.hbm.xml"/>
</session-factory>
</hibernate-configuration>
hbm.xml配置文件

<?xml version="1.0"
encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
   
<!--name 实体类的 包名+
类名       
table数据库的表名   
-->  
 <class name="entity.User"
table="t_user">
    
<!-- name对应实体类的属性id -->
    
<id  name="id"
type="integer">
      
<!-- name 对应数据库的列名id 
-->
      
<column
name="id"></column>

<!--主键的生成策略 native可以适应多种数据库 
increment mysql自动增长策略  sequence oracle自动增长策略
-->
      
<generator
class="native"></generator>

</id>
   
<property name="name">
     
<column
name="name"></column>

</property>
   
   
<property name="pwd">
      
<column
name="pwd"></column>

</property>
   
<property name="age">
      
<column
name="age"></column>

</property>
 </class>

</hibernate-mapping>

hibernate.cfg.xml配置文件和hbm.xml配置文件的更多相关文章

  1. hibernate.cfg.xml配置文件和hbm.xml配置文件 模板

    hibernate.cfg.xml配置文件格式 <?xml version="1.0" encoding="UTF-8"?><!DOCTYPE ...

  2. Hibernate的配置文件 Hibernate.cfg.xml与xxx.hbm.xml

    1.hibernate.cfg.xml配置如下: (数据库连接配置) <?xml version="1.0" encoding="UTF-8"?>& ...

  3. Hibernate(七):*.hbm.xml配置文件中Set三个属性

    背景: 在上一篇文章中实现双向关联时,其中在Customer.java中我们使用了java.util.List<Order>来关联多的Order.其实还有另外一种实现方法:使用java.u ...

  4. eclipse hibernate配置文件(*.hbm.xml)加上自动提示功能

    转自:https://blog.csdn.net/u012217085/article/details/17397843?utm_source=blogkpcl3 1. 标签:hibernate 在编 ...

  5. hibernate笔记--实体类映射文件"*.hbm.xml"详解

    实体类就是指普通的POJO,Hibernate并不知道那个实体类对应数据库的哪一张表,所以还需要配置一下,常用的方式就是*.hbm.xml文件[配置与@注解配置,这里介绍前者的详细属性: <?x ...

  6. 为PO手写添加配置文件(hbm.xml)

  7. Hibernate学习(3)- *.hbm.xml详解

    <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-mapping PUBL ...

  8. 【转】Hibernate映射机制之XXX.hbm.xml

    http://blog.csdn.net/a9529lty/article/details/6454924[注意多对一中“多”和“一”各自的java文件.xml文件的书写格式] 另外两篇总结:http ...

  9. intellij 编译 springmvc+hibernate+spring+maven 找不到hbm.xml映射文件

    1. 错误信息 Invocation of init method failed; nested exception is org.hibernate.MappingNotFoundException ...

随机推荐

  1. mysql中select五种子句和统计函数

    select 五种子句顺序 where 条件 group by 分组 having 把结果进行再次筛选 order by  排序 limit  取出条目 统计函数  max(列名)  求最大 min( ...

  2. Jquery.Datatables 导出excel

    按钮(Buttons) BUttons v1.1.2 下载地址:http://pan.baidu.com/s/1c0Jhckg JSZip v2.5.0-21-g4fd4fc1 下载地址:http:/ ...

  3. EF – 问题集锦

    1.对一个或多个实体的验证失败.有关详细信息,请参见“EntityValidationErrors”属性 在EF5.0修改实体的时候,出现“对一个或多个实体的验证失败.有关详细信息,请参见“Entit ...

  4. poj 2155:Matrix(二维线段树,矩阵取反,好题)

    Matrix Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 17880   Accepted: 6709 Descripti ...

  5. COALESCE NVL NVL2 DECODE

    1 COALESCE 語法:COALESCE(expr1, expr2, ..., exprn) n>=2 作用:COALESCE returns the first non-null expr ...

  6. 数据结构之图 Part1

    Part 1 预计使用7天的时间来过掉图相关的数据结构.第一天主要是一天图的基本概念,熟练掌握定义是一切交流和沟通的基础. 1定义 1.1图 有穷非空顶点,外加边. G(V,E) Graph Vert ...

  7. Windows 历史

  8. 用PHPcms V9四步完成WAP手机站搭建

    用PHPCMS最新发布的V9搭建了ONOW中文网,WEB网站(www.onow.cn)完成后,有用户提供手机访问的问题, 于是着手搭建ONOW手机WAP站(3g.onow.cn). 用PHPCMS V ...

  9. thinkphp 两表、三表联合查询

    //两表联合查询 $Model = M('T1');$Model->join('left join t2 on t1.cid = t2.id')->select();// $list = ...

  10. WORD2007多级列表

    转自玄鸟翩翩 http://hi.baidu.com/shine_yen http://hi.baidu.com/shine_yen/item/01ff2255043bc1aeacc85722 用Wo ...