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

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

      在使用 JPA 映射類時(shí),為什么有人要在 getter 或

      Why should anybody put annotations on the getters or setters when using JPA to map the classes?(在使用 JPA 映射類時(shí),為什么有人要在 getter 或 setter 上添加注釋?)
      • <bdo id='SGr3R'></bdo><ul id='SGr3R'></ul>

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

              <tbody id='SGr3R'></tbody>

                <tfoot id='SGr3R'></tfoot>
                <legend id='SGr3R'><style id='SGr3R'><dir id='SGr3R'><q id='SGr3R'></q></dir></style></legend>
              • <small id='SGr3R'></small><noframes id='SGr3R'>

              • 本文介紹了在使用 JPA 映射類時(shí),為什么有人要在 getter 或 setter 上添加注釋?的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

                問題描述

                主題說明了一切......到目前為止,我認(rèn)為人們?cè)?getter 和/或 setter 上聲明注釋沒有任何優(yōu)勢(shì).對(duì)我來(lái)說,這只是將注釋分散到類中的缺點(diǎn),這會(huì)使類更不可讀.

                Subject says it all... I see no advantage of people declaring annotations on the getters and/or setters so far. For me this only has the disadvantage of spreading the annotations over the class, which can make the class more unreadable.

                在字段上添加注釋明顯減少了需要幫助時(shí)發(fā)布的代碼量.不過,這只是一個(gè)很小的優(yōu)勢(shì).但是在方法上添加注釋對(duì)我來(lái)說毫無(wú)用處.

                Putting the annotations on the fields clearly reduces the amount of code to post when needing help. This is just a tiny advantage though. But putting annotations on methods would serve no purpose to me.

                推薦答案

                在方法上添加注釋會(huì)強(qiáng)制 JPA 通過方法訪問屬性.當(dāng)對(duì)象的內(nèi)部狀態(tài)與數(shù)據(jù)庫(kù)模式不同時(shí),這是有意義的:

                Putting annotations on methods forces JPA to access properties via methods. It makes sense when internal state of your object differs from the database schema:

                @Entity
                public class Employee {
                    private String firstName;
                    private String lastName;
                
                    @Column(name = "EMP_NAME") // Due to legacy database schema
                    public String getName() {
                        return fisrtName + " " + lastName;
                    }
                
                    public void setName(String name) {
                        ...
                    }
                
                    ... Getters and setters for firstName and lastName with @Transient ...
                }
                

                在 JPA 2.0 中,您可以使用 @Access 在細(xì)粒度級(jí)別指定訪問類型:

                In JPA 2.0 you can specify access type at fine-grained level with @Access:

                @Entity @Access(AccessType.FIELD)
                public class Employee {
                    @Access(AccessType.PROPERTY) @Column(name = "EMP_NAME")
                    public String getName() { ... }
                    ... other properties have field access ...
                }
                

                這篇關(guān)于在使用 JPA 映射類時(shí),為什么有人要在 getter 或 setter 上添加注釋?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(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á)式的類型是什么?)
                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ǔ)?)
              • <small id='LPfGG'></small><noframes id='LPfGG'>

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

                      <bdo id='LPfGG'></bdo><ul id='LPfGG'></ul>

                          <tfoot id='LPfGG'></tfoot>

                        • <legend id='LPfGG'><style id='LPfGG'><dir id='LPfGG'><q id='LPfGG'></q></dir></style></legend>

                          主站蜘蛛池模板: 国产精品一区二区av | av日韩在线播放 | 国产综合精品 | www国产亚洲精品 | 日韩成人一区二区 | 欧美精品1区2区3区 精品国产欧美一区二区 | 91在线精品一区二区 | 这里只有精品999 | 伊人久久一区二区 | 亚洲欧美日韩一区二区 | 亚洲成人一二区 | 国产精品久久久久久久久久 | 国产成人一区在线 | 欧美精品一区免费 | 91久久国产综合久久91精品网站 | 久久久久久黄 | 国产 91 视频 | 亚洲黄色在线免费观看 | 伊人超碰在线 | 神马九九 | 在线免费av观看 | 在线午夜电影 | 久久9视频 | 国产精品免费在线 | 天天操天天拍 | 成人免费视频一区 | 国产精品国产自产拍高清 | 亚洲视频在线播放 | 久久精品视频在线免费观看 | 自拍视频一区二区三区 | 久久手机在线视频 | 黄色大片在线免费观看 | 亚洲精品免费视频 | 在线成人精品视频 | 91视频播放| 日韩欧美国产精品综合嫩v 一区中文字幕 | 天天影视色综合 | 在线91 | 日韩精品一区二区三区中文在线 | 成人精品免费视频 | 成年女人免费v片 |