OneToOne relation with a Joined Inheritance abstract class

Viewed 373

I have some class with an InheritanceType.JOINED like:

@SuppressWarnings("serial")
@Entity
@Audited
@Inheritance(strategy=InheritanceType.JOINED)
public abstract class A{
//some fields
}

Then I have 3 classes (B, C, D) that extend A like this one:

@SuppressWarnings("serial")
@Entity
@Audited
public class B extends A{
//fields
}

Now I want reference to these class inside another class, named W. So I put this relation:

 @OneToOne
private A a;

But when I get the object of W from my database the field of a is always null, and I think because it is an Abstract class.

So my question is: how can I create a OneToOne relation between W and all the concrete classes if I can't use A as field?

0 Answers
Related