title: Advanced search for java code
body: <p>Is there any easy way to get advanced search in Java code? I'm migrating our application from Glassfish 2 to Glassfish 4. Few libraries changed their way of handling inputs and I would like find where this specific situations will occur.</p>
  
  <p>For example:
  JPA 1.2</p>
  
  <pre><code>MyEntity some = entityManager.find(MyEntity.class, 1234);
  some.setIdMyEntity(null);
  entityManager.persist(some);
  </code></pre>
  
  <p>Code similar to this above was working in a way it persisted new entity with new auto generated id (if appropriate annotation was in entity).</p>
  
  <p>JPA 2.2
  The same code will produce error</p>
  
  <pre><code>The attribute [idMyEntity] of class [my.package.MyEntity] is mapped to a primary key column in the database. Updates are not allowed.
  </code></pre>
  
  <p>I understand reasons behind this change and I would like to fix my application and find places which need fix as precisely as it is possible.</p>
  
  <p>To find these I used regular expression <code>\.setId[a-zA-Z]+\(null\);</code> However there are hundreds or even thousands of matches and 90% are false positives. That's why I would search engine which could do something like that:</p>
  
  <pre><code>Look for invocation of setter (which is related to field annotated as @Id) 
  with argument null on object which is instance of class annotated as @Entity
  </code></pre>
  
  <p>As I told this is only example so basically what I'm looking for are ways of advanced searching in Java code.
  Anything more than dead simple search/ regular expression search/ find usages capabilities are welcome.</p>