title: How to automatically move annotations from methods to fields?
body: <p>I have a large number of Java classes using JPA property access instead of field access, and converting them to use field access (moving the annotations from getters to fields) is time consuming. Re-generating them from database tables is also not an option.</p>
  
  <p>So I was looking at using IDEA's structural search and replace to try move the annotations automatically. I'm wanting to change a class that looks like this:</p>
  
  <pre><code>@Entity
  @Table
  public class Make {
  
      private Long id;
      private String makeCode;
      ...other properties, with more involved JPA annotations
  
      @Id
      @GeneratedValue
      public Long getId() {
          return id;
      }
  
      public void setId(Long id) {
          this.id = id;
      }
  
      @Column(length = 10, unique = true)
      public String getMakeCode() {
          return makeCode;
      }
  
      public void setMakeCode(String makeCode) {
          this.makeCode = makeCode;
      }
      ...
  }
  </code></pre>
  
  <p>to one that looks like this:</p>
  
  <pre><code>@Entity
  @Table
  public class Make {
  
      @Id
      @GeneratedValue
      private Long id;
  
      @Column(length = 10, unique = true)
      private String makeCode;
  
      public Long getId() {
          return id;
      }
  
      public void setId(Long id) {
          this.id = id;
      }
  
      public String getMakeCode() {
          return makeCode;
      }
  
      public void setMakeCode(String makeCode) {
          this.makeCode = makeCode;
      }
      ...
  }
  </code></pre>
  
  <p>From there I'll be able to do additional refactoring, but I'm finding that moving the annotations manually is very time-consuming. </p>
  
  <p>I've played around with structural search &amp; replace, but its quite dense and lacking documentation, so I'd appreciate any tips on how to configure the different templates.</p>
  
  <p>I imagine it would be something like:</p>
  
  <blockquote>
    <p>find all methods starting with "get" that are annotated with at least
    one <code>javax.persistence.*</code> annotation, along with a matching private
    field, and replace with the same field and method, but move the
    annotations from method to field.</p>
  </blockquote>
  
  <p>I'm just struggling to put that into the structural search expressions.</p>