hibernate hbm.xml配置文件说明

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

   <class name="com.oreilly.hh.Track" table="TRACK">
     <meta attribute="class-description">
        Represents a single playable track in the music database.
        @author Jim Elliot(with help from Hibernate)
     </meta>
    
     <id name="id" type="int" column="TRACK_ID">
       <meta attribute="scope-set">protected</meta>
          <generator class="native"/>
     </id>
    
     <property name="title" type="string" not-null="true"/>
    
     <property name="filePath" type="string" not-null="true"/>
    
     <property name="playTime" type="time">
        <meta attribute="field-description">Playing time</meta>
     </property>
    
     <property name="added" type="date">
        <meta attribute="field-description">When the track was created</meta>
     </property>
    
     <property name="volume" type="short" not-null="true">
        <meta attribute="field-description">How loud to play the track</meta>
     </property>
    
   </class>
</hibernate-mapping>
     说明如下:

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

用于导言说明,说明它的文件格式定义。

2.<hibernate-mapping>标签里是真正的映射。

3.<class name="com.oreilly.hh.Track" table="TRACK">
定义一个类com.oreilly.hh.Track的映射。(可以定义任意多个类在一个映射文件里)。表示存在数据库表TRACK中。

4. <meta attribute="class-description">
        Represents a single playable track in the music database.
        @author Jim Elliot(with help from Hibernate)
     </meta>
定义了说明,可以被JavaDoc读取。

5.  <id name="id" type="int" column="TRACK_ID">
       <meta attribute="scope-set">protected</meta>
          <generator class="native"/>
     </id>
 定义了类属性和数据库表列的映射。   <generator class="native"/>是表示ID生成策略,此种策略有多种。

6. <property name="volume" type="short" not-null="true">
        <meta attribute="field-description">How loud to play the track</meta>
  </property>                                                                                                                                                                                          定义了说明,可以被JavaDoc读取。




 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值