久久久久久久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 映射類時,為什么有人要在 getter 或

      Why should anybody put annotations on the getters or setters when using JPA to map the classes?(在使用 JPA 映射類時,為什么有人要在 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 映射類時,為什么有人要在 getter 或 setter 上添加注釋?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                主題說明了一切......到目前為止,我認為人們在 getter 和/或 setter 上聲明注釋沒有任何優勢.對我來說,這只是將注釋分散到類中的缺點,這會使類更不可讀.

                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.

                在字段上添加注釋明顯減少了需要幫助時發布的代碼量.不過,這只是一個很小的優勢.但是在方法上添加注釋對我來說毫無用處.

                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.

                推薦答案

                在方法上添加注釋會強制 JPA 通過方法訪問屬性.當對象的內部狀態與數據庫模式不同時,這是有意義的:

                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 在細粒度級別指定訪問類型:

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

                這篇關于在使用 JPA 映射類時,為什么有人要在 getter 或 setter 上添加注釋?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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 原語?)
              • <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>

                          主站蜘蛛池模板: 日韩在线免费视频 | 免费成人午夜 | 国产成人精品一区二区三区 | 日韩精品在线免费 | 国产高清视频在线 | 精品视频一区二区三区 | 精品在线一区 | 精品国产一区二区国模嫣然 | 久久久久国产精品 | 在线国产精品一区 | 小h片免费观看久久久久 | 久热爱| 精品视频在线免费观看 | 日韩欧美国产一区二区 | 久久国产精品网站 | 中文字幕成人在线 | 日韩在线第一 | 伊人精品久久久久77777 | 国产精品视频二区三区 | 中文字幕在线免费视频 | 精品美女在线观看 | 18成人在线观看 | 亚洲精品福利在线 | 亚洲一区二区精品视频 | 亚洲欧美一区二区三区国产精品 | 精品久久久精品 | aaa精品| 亚洲视频三 | 国产精品美女久久久久aⅴ国产馆 | 久久不卡 | 国产在线一区观看 | 人人干免费 | 成人动漫视频网站 | 久久er精品 | 久久一区二 | 亚洲成年在线 | 免费在线观看黄色av | 日韩欧美在线观看 | 成人av一区二区在线观看 | 亚洲成人综合在线 | 亚洲精品一区二区三区中文字幕 |