国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學(xué)院 > 開發(fā)設(shè)計(jì) > 正文

hbm2java和hbm2ddl工具的使用

2019-11-18 11:52:56
字體:
供稿:網(wǎng)友

  hbm2java是根據(jù)映射文件自動(dòng)生成java源文件
  
  hbm2ddl 是根據(jù)映射文件自動(dòng)生成數(shù)據(jù)庫schema
  
  XDoclet 根據(jù)帶有XDoclet的標(biāo)記的java源文件生成映射文件
  
  Middlegen 根據(jù)數(shù)據(jù)庫Schema自動(dòng)生成映射文件
  
  1'<class name = "mypack.customer">
  
  <meta attribute = "class-description">//指定下列為注釋
  Repesents a single customer
  @author S
  </meta>
  </class>
  
  2'<class name = "mypack.customer">
  
  <meta attribute = "extends">mypack.BusinessObject</meta>//指定類所繼續(xù)的類
  </class>
  
  3'<property name = "married" type ="boolean" column ="is_married">
  
  <meta attribute = "field-description">is the customer married </meta>//指定方法注釋
  </property>
  
  4'指定類、類的屬性及類屬性的get方法和set方法的修飾符可選:
  
  static 、 public 、 abstract 、final 、 PRivate
  
  <id name = "id" type = "int">
  <meta attribute = "scope-set">protected</meta>
  <generator class = "native">
  </id>
  
  5'指定在類的toString()方法返回的字符串中是否包含特定的屬性
  
  <property name ="name" type ="string" not-null = "true">
  <meta attribute ="use-in-tostring">true</meta>
  </property>
  
  ////////////////<meta>的元素屬性表
  
  class-description//指定描述類的javaDoc
  
  field-description//指定描述類的屬性的javaDoc
  
  interface//假如為true,表示生成接口而非類,默認(rèn)為false
  
  implements//指定類所實(shí)現(xiàn)的接口
  
  extends//指定類繼續(xù)的父類名
  
  generated-class//重新指定生成的類名
  
  scope-class//指定類的修飾符默認(rèn)為public
  
  scope-set//指定set方法的修飾符默認(rèn)為public
  
  scope-get//指定get方法的修飾符默認(rèn)為public
  
  scope-field//指定類的屬性修飾符默認(rèn)為private
  
  use-in-toString//假如為true,表示在tostring方法中包含此屬性
  
  gen-property//假如為false不會(huì)在java類中生成此屬性,默認(rèn)為true
  
  finder-method//指定find方法名
  
  ///////////////<column>制定數(shù)據(jù)庫表
  
  1'設(shè)定字段名、字段長度以及唯一性
  
  <property name = "name" type ="string">
  <meta attribute ="use-in-tostring">true</meta>
  <column name ="name" length ="15" not-null ="true" unique ="true">
  </property>//表示字段名為name長度為15不能為空具有唯一性
  
  2'設(shè)定字段不為空,并且為這個(gè)字段設(shè)立檢查約束。
  
  <property name = "age" type ="int">
  <meta attribute = "field-description">How old is the customer</meta>
  <meta attribute = "use-in-tostring">true</meta>
  <column name = "age" check ="age > 10" not-null ="true">
  </property>
  
  3'建立索引
  
  <property name = "registeredtime" type ="timestamp">
  <meta attribute ="field-description">When the customer was registered</meta>
  <meta attribute ="use-in-tostring">true</meta>
  <column name ="registerd_time" index = "idx_registerd_time" sql-type= "timestamp">
  </property>
  
  4'建立對應(yīng)的字段類型
  
  <property name = "description" type ="string">
  <meta attribute ="use-in-tostring">true</meta>
  <column name = "description" sql-type ="text">//根據(jù)相對應(yīng)的數(shù)據(jù)庫來定義字段的類型
  </property>

發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 什邡市| 灌云县| 凌海市| 宁都县| 大渡口区| 云林县| 林州市| 乡城县| 赤城县| 新兴县| 巴马| 祥云县| 株洲市| 富宁县| 青田县| 昆明市| 宜宾市| 和田县| 彰武县| 鄂托克前旗| 望江县| 阿坝县| 印江| 盐源县| 桃园市| 鲁甸县| 兴城市| 甘南县| 延庆县| 师宗县| 阿图什市| 建昌县| 临沧市| 开化县| 军事| 商南县| 宜君县| 桦川县| 崇阳县| 五家渠市| 冀州市|