POJO类与数据库表的映射文件的编写

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/wo3002807/article/details/11590175

######.hbm.xml配置信息

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC  "-//Hibernate/Hibernate Mapping DTD//EN"   "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> 
<hibernate-mapping>
   <class name="类全名" table="数据库表">
      <meta attribute="class-description"> This class contains the employee detail.   </meta>
    
     <!--类属性名与数据库表中的字段名关联-->      
      <id name="id" type="int" column="id">
         <!--
           hibernate提供的内置标识符生成器:
           (1)increment:由hibernate自动递增的方式生成标识符;
           (2)identity:由数据底层数据库生成标识符;
           (3)sequence:hibernate根据底层数据库的序列来生成标识符;
           (4)hilo:hibernate根据hig/low算法来生成标识符;
           (5)native:根据底层数据库对自动生成标识符的支持能力,来选择identity,sequence或hilo。
           (6)uuid.hex:hibernate采用128位的uuid算法来生成标识符;
          (7)assigned:有java应用程序负责生成标识符。        
         -->
 <generator class="内置标识符"/>
     </id>
     <!--第一种方式-->
            <property name="类属性名" column="表字段名" type="数据类型"/>
      <!--第二种方式-->
      <property name="类属性名"  type="数据类型"><column name="表字段名" sql-type="数据类型"/></property>
   </class>
</hibernate-mapping>
 
 
POJO类的数据类型与数据库表字段的数据类型的映射关系。

 


猜你喜欢

转载自blog.csdn.net/wo3002807/article/details/11590175
今日推荐