久久久久久久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 注釋上設(shè)置長(zhǎng)度屬性時(shí)有什么作用

        What does the length attribute do when set on the @Column JPA annontation?(在 @Column JPA 注釋上設(shè)置長(zhǎng)度屬性時(shí)有什么作用?)
          <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 注釋上設(shè)置長(zhǎng)度屬性時(shí)有什么作用?的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

                  問(wèn)題描述

                  在 JPA 中設(shè)置列??的長(zhǎng)度到底有什么作用?

                  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;
                  }
                  

                  我知道您可以使用注釋來(lái)基于實(shí)體對(duì)象生成數(shù)據(jù)庫(kù)架構(gòu) (DDL),但是長(zhǎng)度是否會(huì)在持久性發(fā)生時(shí)進(jìn)行任何類(lèi)型的檢查或截?cái)?,或者它僅用于架構(gòu)創(chuàng)建?

                  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?

                  我還意識(shí)到 JPA 可以位于各種實(shí)現(xiàn)之上,在這種情況下我關(guān)注的實(shí)現(xiàn)是 Hibernate.

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

                  推薦答案

                  當(dāng)持久性發(fā)生時(shí),長(zhǎng)度是否會(huì)進(jìn)行任何類(lèi)型的檢查或截?cái)啵蛘咚鼉H用于創(chuàng)建模式?

                  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:

                  列長(zhǎng)度.(僅在使用字符串值列時(shí)適用.)

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

                  And 僅在生成的 DDL 中使用.在您的示例中,結(jié)果列將生成為 VARCHAR(32) 并且嘗試插入更長(zhǎng)的字符串會(huì)導(dǎo)致 SQL 錯(cuò)誤.

                  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.

                  對(duì)于驗(yàn)證,您可以添加 @Size(max=32) 約束 來(lái)自 Bean Validation API (JSR 303).我在此處提供了一個(gè)可運(yùn)行測(cè)試的示例.

                  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.

                  同時(shí)提供 Sizelength 似乎是多余的,但根據(jù) 附錄 D. 的 Bean Validation 規(guī)范,生成 Bean Validation-aware DDL 對(duì)于 Persistence Providers 不是強(qiáng)制性的.所以使用 length 作為 DDL,@Size 進(jìn)行驗(yàn)證.

                  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 實(shí)現(xiàn)放在 JPA 2.0 的類(lèi)路徑上.對(duì)于 JPA 1.0,請(qǐng)參閱此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.

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

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

                  相關(guān)文檔推薦

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

                  <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>
                            主站蜘蛛池模板: 91精品国产91久久久久久不卞 | 一级黄色毛片免费 | www亚洲精品 | 看av片网站 | 国产专区在线 | 久久久久国产精品一区二区 | 日本三级全黄三级三级三级口周 | 国产一区影院 | 久久久久久久夜 | www精品美女久久久tv | 中文字幕日本一区二区 | 国产一区二区久久久 | 欧美一区二区三区视频在线观看 | 日韩一二三区视频 | 久久久国产一区 | 亚洲欧美日韩中文字幕一区二区三区 | 国产精品国产成人国产三级 | 日韩欧美网 | 韩国成人在线视频 | 欧美一区 | 黄色片在线 | 亚洲精品乱码久久久久久9色 | 精品在线观看一区二区 | 国产色视频网站 | 亚洲一区二区三 | 久久精品97 | av激情影院 | 国产在线一区观看 | 国产成人综合在线 | 99在线资源 | 国产伊人精品 | 99reav| 狠狠av | 国产精品久久久久久久久久久免费看 | 国产电影精品久久 | 干狠狠 | 欧美精品在欧美一区二区 | 欧美亚洲高清 | 99久久99| 国产一区二区高清在线 | 伊人精品在线 |