1 Reply Latest reply on Jul 29, 2005 5:26 PM by Emmanuel Bernard

    @Inheritance and LAZY / EAGER FetchType.

    Ronald Mathies Newbie

      I've got the following entity's:

      Entity JObject:

      @Entity
      @Table(name = "object")
      @NamedQueries(
       {
       @NamedQuery(name="jobject.findEager",
       queryString="SELECT j FROM JObject AS j" +
       " LEFT JOIN FETCH j.JAnnotations " +
       " WHERE j.name = :objectName AND j.JPackage.name = :packageName")
       }
       )
      @Inheritance(strategy = InheritanceType.SINGLE_TABLE,
       discriminatorType = DiscriminatorType.STRING)
      @DiscriminatorColumn(name = "objectType")
      public class JObject extends EntityBase implements java.io.Serializable {
      
       private Collection<JAnnotation> jAnnotations = null;
      
       public JObject() {
       }
      
       @ManyToMany(fetch = FetchType.LAZY, cascade={CascadeType.ALL})
       @JoinTable(
       table=@Table(name="object_annotation"),
       joinColumns=@JoinColumn(name="objectKey", referencedColumnName="id"),
       inverseJoinColumns=@JoinColumn(name="annotationKey", referencedColumnName="id"))
       public Collection<JAnnotation> getJAnnotations() {
       return jAnnotations;
       }
      
       public void setJAnnotations(Collection<JAnnotation> jAnnotations) {
       this.jAnnotations = jAnnotations;
       }
      }
      
      


      And the entity JClass:

      @Entity
      @NamedQueries(
       {
       @NamedQuery(name="jclass.findEager",
       queryString="SELECT j FROM JClass AS j" +
       " LEFT JOIN FETCH j.JAnnotations " +
       " LEFT JOIN FETCH j.InnerClasses " +
       " WHERE j.name = :className AND j.JPackage.name = :packageName")
       }
       )
      @Inheritance(strategy = InheritanceType.SINGLE_TABLE,
       discriminatorType = DiscriminatorType.STRING, discriminatorValue = "class")
      public class JClass extends JObject implements java.io.Serializable {
      
       private Collection<JClass> innerClasses = null;
      
       public JClass() {
       }
      
       @ManyToMany(fetch=FetchType.LAZY, cascade = {CascadeType.ALL})
       @JoinTable(
       table=@Table(name="outerclass_innerclass"),
       joinColumns=@JoinColumn(name="outerClassKey", referencedColumnName="id"),
       inverseJoinColumns=@JoinColumn(name="innerClassKey", referencedColumnName="id")
       )
       public Collection<JClass> getInnerClasses() {
       return innerClasses;
       }
      
       public void setInnerClasses(Collection<JClass> innerClasses) {
       this.innerClasses = innerClasses;
       }
      
      }
      


      If i deploy these entity's JBoss is complaining about the named query: jclass.findEager


      could not resolve property: InnerClasses of: com.jinstance.javalibrary.j2ee.ejb.JClass [SELECT j FROM com.jinstance.javalibrary.j2ee.ejb.JClass AS j LEFT JOIN FETCH j.JAnnotations LEFT JOIN FETCH j.JFields LEFT JOIN FETCH j.JOperators LEFT JOIN FETCH j.InnerClasses WHERE j.name = :className AND j.JPackage.name = :packageName]


      But as you can see this property does excist.
      If i disable the LEFT JOIN FETCH j.InnerClasses then the deployment succeeds without any problem.

      Why do i get this error message?

      Environment:
      JBoss 4.02
      EJB3 Beta