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

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

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

    <tfoot id='HGo7O'></tfoot>

        • <bdo id='HGo7O'></bdo><ul id='HGo7O'></ul>

        Hibernate Annotations - 哪个更好,字段访问还是属性

        时间:2023-07-26
        <i id='cp5gq'><tr id='cp5gq'><dt id='cp5gq'><q id='cp5gq'><span id='cp5gq'><b id='cp5gq'><form id='cp5gq'><ins id='cp5gq'></ins><ul id='cp5gq'></ul><sub id='cp5gq'></sub></form><legend id='cp5gq'></legend><bdo id='cp5gq'><pre id='cp5gq'><center id='cp5gq'></center></pre></bdo></b><th id='cp5gq'></th></span></q></dt></tr></i><div id='cp5gq'><tfoot id='cp5gq'></tfoot><dl id='cp5gq'><fieldset id='cp5gq'></fieldset></dl></div>
        <tfoot id='cp5gq'></tfoot>
          <tbody id='cp5gq'></tbody>
          • <bdo id='cp5gq'></bdo><ul id='cp5gq'></ul>

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

                <legend id='cp5gq'><style id='cp5gq'><dir id='cp5gq'><q id='cp5gq'></q></dir></style></legend>
                1. 本文介绍了Hibernate Annotations - 哪个更好,字段访问还是属性访问?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  这个问题与Hibernate Annotation Placement Question有些相关.

                  但我想知道哪个更好?通过属性访问还是通过字段访问?各有什么优缺点?

                  But I want to know which is better? Access via properties or access via fields? What are the advantages and disadvantages of each?

                  推荐答案

                  我更喜欢访问器,因为我可以在需要时向访问器添加一些业务逻辑.这是一个例子:

                  I prefer accessors, since I can add some business logic to my accessors whenever I need. Here's an example:

                  @Entity
                  public class Person {
                  
                    @Column("nickName")
                    public String getNickName(){
                       if(this.name != null) return generateFunnyNick(this.name);
                       else return "John Doe";
                    }
                  }
                  

                  此外,如果您将其他库放入混合中(例如一些 JSON 转换库或 BeanMapper 或 Dozer 或其他基于 getter/setter 属性的 bean 映射/克隆库),您将保证该库是同步的使用持久性管理器(都使用 getter/setter).

                  Besides, if you throw another libs into the mix (like some JSON-converting lib or BeanMapper or Dozer or other bean mapping/cloning lib based on getter/setter properties) you'll have the guarantee that the lib is in sync with the persistence manager (both use the getter/setter).

                  这篇关于Hibernate Annotations - 哪个更好,字段访问还是属性访问?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何从常量 java 为注解提供值 下一篇:我需要&lt;class&gt;persistence.xml 中的元素?

                  相关文章

                  最新文章

                  <small id='61g9E'></small><noframes id='61g9E'>

                2. <i id='61g9E'><tr id='61g9E'><dt id='61g9E'><q id='61g9E'><span id='61g9E'><b id='61g9E'><form id='61g9E'><ins id='61g9E'></ins><ul id='61g9E'></ul><sub id='61g9E'></sub></form><legend id='61g9E'></legend><bdo id='61g9E'><pre id='61g9E'><center id='61g9E'></center></pre></bdo></b><th id='61g9E'></th></span></q></dt></tr></i><div id='61g9E'><tfoot id='61g9E'></tfoot><dl id='61g9E'><fieldset id='61g9E'></fieldset></dl></div>

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

                      <bdo id='61g9E'></bdo><ul id='61g9E'></ul>

                    1. <tfoot id='61g9E'></tfoot>