久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

<i id='1KtjU'><tr id='1KtjU'><dt id='1KtjU'><q id='1KtjU'><span id='1KtjU'><b id='1KtjU'><form id='1KtjU'><ins id='1KtjU'></ins><ul id='1KtjU'></ul><sub id='1KtjU'></sub></form><legend id='1KtjU'></legend><bdo id='1KtjU'><pre id='1KtjU'><center id='1KtjU'></center></pre></bdo></b><th id='1KtjU'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='1KtjU'><tfoot id='1KtjU'></tfoot><dl id='1KtjU'><fieldset id='1KtjU'></fieldset></dl></div>
  • <small id='1KtjU'></small><noframes id='1KtjU'>

      • <bdo id='1KtjU'></bdo><ul id='1KtjU'></ul>

      1. <legend id='1KtjU'><style id='1KtjU'><dir id='1KtjU'><q id='1KtjU'></q></dir></style></legend>

        <tfoot id='1KtjU'></tfoot>

        在 @Column JPA 注釋上設置長度屬性時有什么作用

        What does the length attribute do when set on the @Column JPA annontation?(在 @Column JPA 注釋上設置長度屬性時有什么作用?)
          <tbody id='e93OG'></tbody>
        <legend id='e93OG'><style id='e93OG'><dir id='e93OG'><q id='e93OG'></q></dir></style></legend>

            <bdo id='e93OG'></bdo><ul id='e93OG'></ul>
          • <i id='e93OG'><tr id='e93OG'><dt id='e93OG'><q id='e93OG'><span id='e93OG'><b id='e93OG'><form id='e93OG'><ins id='e93OG'></ins><ul id='e93OG'></ul><sub id='e93OG'></sub></form><legend id='e93OG'></legend><bdo id='e93OG'><pre id='e93OG'><center id='e93OG'></center></pre></bdo></b><th id='e93OG'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='e93OG'><tfoot id='e93OG'></tfoot><dl id='e93OG'><fieldset id='e93OG'></fieldset></dl></div>

                  <small id='e93OG'></small><noframes id='e93OG'>

                  <tfoot id='e93OG'></tfoot>
                  本文介紹了在 @Column JPA 注釋上設置長度屬性時有什么作用?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  在 JPA 中設置列??的長度到底有什么作用?

                  What exactly does setting the length on a column do in JPA?

                  @Column(name = "middle_name", nullable = false, length = 32)
                  public String getMiddleName() {
                      return this.middleName;
                  }
                  

                  我知道您可以使用注釋來基于實體對象生成數據庫架構 (DDL),但是長度是否會在持久性發生時進行任何類型的檢查或截斷,或者它僅用于架構創建?

                  I understand that you can use the annotations to generate the database schema (DDL) based on the entity objects, but does length do any sort of check or truncation when persistence happens, or it solely used for schema creation?

                  我還意識到 JPA 可以位于各種實現之上,在這種情況下我關注的實現是 Hibernate.

                  I also realize that JPA can sit on top of various implementations, the implementation I am concerned with in this case is Hibernate.

                  推薦答案

                  當持久性發生時,長度是否會進行任何類型的檢查或截斷,或者它僅用于創建模式?

                  Does length do any sort of check or truncation when persistence happens, or it solely used for schema creation?

                  Column注解用于指定:

                  The length attribute of the Column annotation is used to specify:

                  列長度.(僅在使用字符串值列時適用.)

                  The column length. (Applies only if a string-valued column is used.)

                  And 僅在生成的 DDL 中使用.在您的示例中,結果列將生成為 VARCHAR(32) 并且嘗試插入更長的字符串會導致 SQL 錯誤.

                  And is only used in the generated DDL. In your example, the resulting column would be generated as a VARCHAR(32) and trying to insert a longer string would result in an SQL error.

                  對于驗證,您可以添加 @Size(max=32) 約束 來自 Bean Validation API (JSR 303).我在此處提供了一個可運行測試的示例.

                  For validation, you could add a @Size(max=32) constraint from the Bean Validation API (JSR 303). I provided a sample with a runnable test here.

                  同時提供 Sizelength 似乎是多余的,但根據 附錄 D. 的 Bean Validation 規范,生成 Bean Validation-aware DDL 對于 Persistence Providers 不是強制性的.所以使用 length 作為 DDL,@Size 進行驗證.

                  Providing both Size and length may seem redundant but according to the Appendix D. of the Bean Validation spec, generating Bean Validation-aware DDL is not mandatory for Persistence Providers. So use length for the DDL, @Size for validation.

                  如果您有興趣,只需將 Bean Validation 實現放在 JPA 2.0 的類路徑上.對于 JPA 1.0,請參閱此previous answer.

                  In case you're interested, just put a Bean Validation implementation on the classpath with JPA 2.0. With JPA 1.0, refer to this previous answer.

                  這篇關于在 @Column JPA 注釋上設置長度屬性時有什么作用?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  quot;Char cannot be dereferencedquot; error(“Char 不能被取消引用錯誤)
                  Java Switch Statement - Is quot;orquot;/quot;andquot; possible?(Java Switch 語句 - 是“或/“和可能的?)
                  Java Replace Character At Specific Position Of String?(Java替換字符串特定位置的字符?)
                  What is the type of a ternary expression with int and char operands?(具有 int 和 char 操作數的三元表達式的類型是什么?)
                  Read a text file and store every single character occurrence(讀取文本文件并存儲出現的每個字符)
                  Why do I need to explicitly cast char primitives on byte and short?(為什么我需要在 byte 和 short 上顯式轉換 char 原語?)

                  <i id='jljLb'><tr id='jljLb'><dt id='jljLb'><q id='jljLb'><span id='jljLb'><b id='jljLb'><form id='jljLb'><ins id='jljLb'></ins><ul id='jljLb'></ul><sub id='jljLb'></sub></form><legend id='jljLb'></legend><bdo id='jljLb'><pre id='jljLb'><center id='jljLb'></center></pre></bdo></b><th id='jljLb'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='jljLb'><tfoot id='jljLb'></tfoot><dl id='jljLb'><fieldset id='jljLb'></fieldset></dl></div>

                          <tbody id='jljLb'></tbody>
                      • <legend id='jljLb'><style id='jljLb'><dir id='jljLb'><q id='jljLb'></q></dir></style></legend>
                      • <small id='jljLb'></small><noframes id='jljLb'>

                        <tfoot id='jljLb'></tfoot>
                            <bdo id='jljLb'></bdo><ul id='jljLb'></ul>
                            主站蜘蛛池模板: 美国av毛片| 日韩精品在线观看一区二区 | 51ⅴ精品国产91久久久久久 | 亚洲欧美一区二区三区1000 | 亚洲一区二区免费视频 | 久热免费在线 | 精品国产一区探花在线观看 | 成年人精品视频在线观看 | 国产福利91精品 | 成在线人视频免费视频 | 日本午夜视频 | 欧美亚洲另类在线 | 国产99久久久久 | 国产乱肥老妇国产一区二 | 免费av手机在线观看 | 亚洲午夜视频在线观看 | 亚洲一区免费 | 一级片网址 | 久久久久国产精品午夜一区 | 粉嫩一区二区三区性色av | 欧美a免费 | 国内成人免费视频 | 91精品国产一区二区三区 | 日日干日日射 | www.久久精品| 在线欧美亚洲 | 亚洲欧美精品在线观看 | 欧美日本亚洲 | 国产激情网 | 国产福利资源在线 | 国产黄色在线观看 | 正在播放亚洲 | 91精品国产综合久久久动漫日韩 | 91资源在线观看 | 欧美日韩在线精品 | 国产精品视频播放 | 国产成人综合在线 | 中文字幕亚洲精品 | 国产91av视频 | 久久性色 | 亚洲成人二区 |