久久久久久久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>

                          主站蜘蛛池模板: 亚洲精品黄色 | 亚洲成人一区二区 | 午夜在线影院 | 青草在线视频 | av黄色在线观看 | 亚洲高清视频在线 | 好色婷婷| 亚洲亚洲人成综合网络 | 欧美一区二区三区在线视频 | 成人免费毛片嘿嘿连载视频 | 欧美一级在线视频 | 一区二区三区四区在线播放 | 国产精品偷乱一区二区三区 | 日韩免费在线观看视频 | 免费在线成人网 | 欧美日韩色 | 国产一级黄色 | 精品国产999久久久免费 | 成人国产在线观看 | 一区二区三区不卡视频 | 国产视频黄色 | 日本少妇视频 | av手机天堂 | 亚洲怡春院 | 国产精品国产精品国产专区不卡 | www视频在线观看网站 | 高清免费视频日本 | 国产一区二区三区四区 | 欧美日韩啪啪 | 精品日韩一区二区三区 | 精品影院 | www中文字幕 | 日韩毛片在线播放 | 天天视频黄| 国产免费av在线 | 一区二区三区影视 | 在线观看不卡av | 久久久成人免费视频 | 久久久精品国产sm调教网站 | 麻豆成人免费视频 | 国产成人免费视频 |