0 Replies Latest reply on Jan 29, 2008 9:58 AM by hamtho2

    @Embedded objects within inheritance-strategy

      Hi,

      I have the problem, that when I use an @Embedded object within my inheritance-strategy,
      the entities will not be fetched correctly. When I change the annotation to @Transient,
      all corresponding entities are fetched correctly.

      This is an example of my class structure:

      @Entity
      @Table(name="baseClass")
      @Inheritance(strategy=InheritanceType.JOINED)
      public abstract class BaseClass implements Serializable {
      ....
      }
      
      
      @Entity
      @Table(name = "extendedClass")
      @PrimaryKeyJoinColumn(name="id_baseClass")
      public class ExtendedClass extends BaseClass {
      
      ...
      
       @Embedded //@Transient works
       private EmbeddableClass embedded = null;
      }
      
      @Entity
      @Table(name = "anotherExtendedClass")
      @PrimaryKeyJoinColumn(name="id_baseClass")
      public class AnotherExtendedClass extends BaseClass {
      
      ...
      }
      
      
      @Embeddable
      public class EmbeddableClass implements Serializable {
      
       @Column
       private boolean aValue;
      
       @Column
       private boolean anotherValue;
      
      }
      
      @Entity
      @Table(name = "users")
      public class User extends SimpleUser implements Serializable {
      
       @OneToMany(mappedBy = "anotherEntity", cascade={CascadeType.ALL}, fetch=FetchType.LAZY)
       private Collection<BaseClass> baseClassCollection = new Vector<BaseClass>();
      }
      
      


      So when I keep the @Embedded-Annotation, I have all objects of the ExtendedClass, but none
      of the AnotherExtendedClasses. Together with the @Transient-annotation, I receive all entities
      of all inherited-classes from the database.

      Anyone having an idea, why this is not working?

      Thanks
      Thomas