[jboss-user] [EJB 3.0] - @Embedded objects within inheritance-strategy

hamtho2 do-not-reply at jboss.com
Tue Jan 29 09:58:30 EST 2008


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



View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4124429#4124429

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4124429



More information about the jboss-user mailing list