title: Join query for any type mapping on Hibernate
body: <p>I've Implemented Any relationship Tag entity mapping with Asset,Patient,Staff</p>
  
  <p>I tried below JPQL Query</p>
  
  <p><code>em.createQuery("select t from Tag t join t.tagAssociation ta");</code></p>
  
  <p>I got the following error</p>
  
  <blockquote>
    <p>org.hibernate.hql.internal.ast.QuerySyntaxException: An AnyType attribute cannot be join fetched error</p>
  </blockquote>
  
  <p>What is wrong with the query ? 
  How to write join query and I want to fetch Asset and Tag associated list.</p>
  
  <p>Code:</p>
  
  <pre><code> public interface ITagAssociatable {
   public String getName();   
  }
  
   @Entity
   public class Tag {
   @Id
   private String tagSerialNumber;    
  
  @JsonIgnore
  @Any(metaColumn = @Column(name = "tag_association_type"))
  @AnyMetaDef(idType = "long", metaType = "string", metaValues = {
          @MetaValue(targetEntity = Asset.class, value = "Asset"),
          @MetaValue(targetEntity = Staff .class, value = "Staff"),
          @MetaValue(targetEntity = Patient.class, value = "Patient") })
  @Cascade({ org.hibernate.annotations.CascadeType.MERGE })
  @JoinColumn(name = "tag_association_id")
  private ITagAssociatable tagAssociation;
   }
  
      @Entity
      public class Asset implements ITagAssociatable {
  @Id
  private Long id;
  private String name
    }
  
      @Entity
      public class Staff implements ITagAssociatable {
  @Id
  private Long id;
  private String name;
    }
  
      @Entity
      public class Patient implements ITagAssociatable{
  @Id
  private Long id;
  private String name
    }
  </code></pre>