Hello everyone.
I have encountered a problem with inheritance mapping. Here is my class hierarchy with annotations:
@Entity
@org.hibernate.annotations.Entity(polymorphism = PolymorphismType.EXPLICIT)
@Table(name = "EXECUTORS")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "IS_GROUP", discriminatorType = DiscriminatorType.INTEGER)
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public abstract class Executor
@Entity
@DiscriminatorValue(value = "1")
final public class Group extends Executor
@Entity
@DiscriminatorValue(value = "0")
public class Actor extends Executor
There is the following method in another class:
@ManyToOne(fetch = FetchType.LAZY, targetEntity = Executor.class)
@JoinColumn(name = "EXECUTOR_ID", nullable = false, insertable = true, updatable = false)
@Index(name = "EXEC_GROUP_REL_EXEC_ID_IDX")
public Executor getExecutor() {
return executor;
}
The problem is that whenever this method is called Anonymous inner class of Executor is generated (not Actor or Group). Is there any way to make hibernate generate instances of Executor's subclasses, not of abstract Executor class?
Will be grateful for any help.
Thx in advance.
|