<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                # 20.1.1\. 對schema定制化(Customizing the schema) 很多Hibernate映射元素定義了可選的`length`、`precision` 或者 `scale`屬性。你可以通過這個屬性設置字段的長度、精度、小數點位數。 ``` <property name="zip" length="5"/> ``` ``` <property name="balance" precision="12" scale="2"/> ``` 有些tag還接受`not-null`屬性(用來在表字段上生成`NOT NULL`約束)和`unique`屬性(用來在表字段上生成`UNIQUE`約束)。 ``` <many-to-one name="bar" column="barId" not-null="true"/> ``` ``` <element column="serialNumber" type="long" not-null="true" unique="true"/> ``` `unique-key`屬性可以對成組的字段指定一個唯一鍵約束(unique key constraint)。目前,`unique-key`屬性指定的值在生成DDL時_并不會_被當作這個約束的名字,它們只是在用來在映射文件內部用作區分的。 ``` <many-to-one name="org" column="orgId" unique-key="OrgEmployeeId"/> <property name="employeeId" unique-key="OrgEmployee"/> ``` `index`屬性會用對應的字段(一個或多個)生成一個index,它指出了這個index的名字。如果多個字段對應的index名字相同,就會生成包含這些字段的index。 ``` <property name="lastName" index="CustName"/> <property name="firstName" index="CustName"/> ``` `foreign-key`屬性可以用來覆蓋任何生成的外鍵約束的名字。 ``` <many-to-one name="bar" column="barId" foreign-key="FKFooBar"/> ``` 很多映射元素還接受`&lt;column&gt;`子元素。這在定義跨越多字段的類型時特別有用。 ``` <property name="name" type="my.customtypes.Name"/> <column name="last" not-null="true" index="bar_idx" length="30"/> <column name="first" not-null="true" index="bar_idx" length="20"/> <column name="initial"/> </property> ``` `default`屬性為字段指定一個默認值 (在保存被映射的類的新實例之前,你應該將同樣的值賦于對應的屬性)。 ``` <property name="credits" type="integer" insert="false"> <column name="credits" default="10"/> </property> ``` ``` <version name="version" type="integer" insert="false"> <column name="version" default="0"/> </property> ``` `sql-type`屬性允許用戶覆蓋默認的Hibernate類型到SQL數據類型的映射。 ``` <property name="balance" type="float"> <column name="balance" sql-type="decimal(13,3)"/> </property> ``` `check`屬性允許用戶指定一個約束檢查。 ``` <property name="foo" type="integer"> <column name="foo" check="foo > 10"/> </property> ``` ``` <class name="Foo" table="foos" check="bar < 100.0"> ... <property name="bar" type="float"/> </class> ``` **表 20.1\. Summary** | 屬性(Attribute) | 值(Values) | 解釋(Interpretation) | | --- | --- | --- | | `length` | 數字 | 字段長度 | | `precision` | 數字 | 精度(decimal precision) | | `scale` | 數字 | 小數點位數(decimal scale) | | `not-null` | `true&#124;false` | 指明字段是否應該是非空的 | | `unique` | `true&#124;false` | 指明是否該字段具有惟一約束 | | `index` | `index_name` | 指明一個(多字段)的索引(index)的名字 | | `unique-key` | `unique_key_name` | 指明多字段惟一約束的名字(參見上面的說明) | | `foreign-key` | `foreign_key_name` | specifies the name of the foreign key constraint generated for an association, for a `&lt;one-to-one&gt;`, `&lt;many-to-one&gt;`, `&lt;key&gt;`, or `&lt;many-to-many&gt;` mapping element. Note that `inverse="true"` sides will not be considered by `SchemaExport`. 指明一個外鍵的名字,它是為關聯生成的,或者`&lt;one-to-one&gt;`,`&lt;many-to-one&gt;`, `&lt;key&gt;`, 或者`&lt;many-to-many&gt;`映射元素。注意`inverse="true"`在`SchemaExport`時會被忽略。 | | `sql-type` | `SQL 字段類型` | 覆蓋默認的字段類型(只能用于`&lt;column&gt;`屬性) | | `default` | SQL表達式 | 為字段指定默認值 | | `check` | SQL 表達式 | 對字段或表加入SQL約束檢查 | `&lt;comment&gt;`元素可以讓你在生成的schema中加入注釋。 ``` <class name="Customer" table="CurCust"> <comment>Current customers only</comment> ... </class> ``` ``` <property name="balance"> <column name="bal"> <comment>Balance in USD</comment> </column> </property> ``` 結果是在生成的DDL中包含`comment on table` 或者 `comment on column`語句(假若支持的話)。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看