title: How to refer inner enum in JPA CriteriaBuilder
body: <p>I have an Enum inside a class, that stores its entity's value in database, and I want to refer to this column to make query. Here's entities:</p>
  
  <pre><code>public class PostBox{
      private Message message;
  
      @ManyToOne
      @JoinColumn(name = "MESSAGE_ID")
      public Message getMessage() {
          return message;
      }
  
      public void setMessage(Message message) {
          this.message = message;
      }
  }
  
  public class Message{
  
      private Answer answer;
  
      @Column(name = "ANSWER")
      @Enumerated(EnumType.STRING)
      public Answer getAnswer() {
          return answer;
      }
  
      @AllArgsConstructor
      public static enum Answer{
          MAYBE_YES,
          MAYBE_NO,
          MAYBE_I_DONT_KNOW
  
          @Getter
          private final String label;
      }
  }
  </code></pre>
  
  <p>What I want to achive in simple english: <code>Select * from POSTBOX where MESSAGE IN (SELECT * from MESSAGE where ANSWER = MAYBE_NO)</code></p>
  
  <p>Here's what I came with</p>
  
  <pre><code>@Override
  public final Specification&lt;PostBox&gt; byFilter(final PostBoxFilter filter) {
      return new Specification&lt;PostBox&gt;() {  
          @Override    
          public Predicate toPredicate(Root&lt;PostBox&gt; root, CriteriaQuery&lt;?&gt; query, CriteriaBuilder builder) {
              return builder.equal(root.join(PostBox_.message).get(Message_.answer), filter.getAnswer());
          }
      };
  }
  </code></pre>
  
  <p>But it gives <code>error : no suitable method found for get(SingularAttribute&lt;Message,Answer&gt;)</code></p>
  
  <p>How should I access this variable?</p>