title: Invalid Hibernate warning? '@Access(AccessType.PROPERTY) on a field has no effect'
body: <p>I have following entity class User:</p>
  
  <pre><code>public class User implements Serializable {
  
      @Column(length = 10, name = "user_type")
      @Access(AccessType.PROPERTY)
      private String userTypeS;
  
      @Transient
      private UserType userType;
      ...
      public void setUserType(UserType userType) {
          this.userType = userType;
          this.userTypeS = this.userType.getType();
      }
  
      protected void setUserTypeS(String userTypeS) {
          this.userTypeS = userTypeS;
          userType = UserType.toUserType(userTypeS);
      }
  </code></pre>
  
  <p>UserType is an enum.
  This issue was that I could not simply use the <code>@Enumerated</code> annotation to map UserType since the presentation of the enums in the code is different from that in the, e.g.:</p>
  
  <pre><code>public enum UserType {
  CUSTOMER_NON_PRO("custnop") ...
  </code></pre>
  
  <p>When workign with the entity I wanted to be able to set the enum as userType and not the String representation of it. For this I created a public setter that sets the enum (userType) and translates it to the String representation of it (which is mapped with hibernate). Similarly there is a protected setUserTypeS which must be called by hibernate and will map the String userType to the enum UserType.  </p>
  
  <p>For this of course hibernate must use the setters to populate the entity. In our project it is preferred to set the annotations on the properties themselves i.o. the getters/setters. Hence hibernate will set the property values directly using introspection (and will thereby bypass the setters). For userTypeS I indicated that the access type is PROPERTY (i.o. FIELD) and because of that hibernate will call setUSerTypeS.  </p>
  
  <p>All of this works smoothly. The 'problem' is that in our logs we see following warning appear:</p>
  
  <blockquote>
    <p>org.hibernate.cfg.AnnotationBinder - Placing @Access(AccessType.PROPERTY) on a field does not have any effect.</p>
  </blockquote>
  
  <p>This warning does not appear to be correct. If I would remove <code>@Access(AccessType.PROPERTY)</code> from the field userTypeS then hibernate would not call the setter and hence the enum userType would not be set. So, placing <code>@Access(AccessType.PROPERTY)</code> does have affect.   </p>
  
  <p>Is this warning message invalid or outdated or am I misunderstanding something anyway?</p>
  
  <p>thanks,<br>
  Stijn</p>