Hi,
I have a question regarding a descriminator column values
My situation:
I have an main class A which contains an aggregated object of class B. Both classes contain an object identifier attribute which is used to uniquely identify the objects. Now I want to use a discriminator value/column from class B rather than from class A as I do not want to hold the TYPE (in addition to the b OID) in object A.
My question:
The following code snippet does not work as the TYPE column has to be in Class A to work.
I'm wondering if it is possible to use e.g. a DiscriminatorFormular to reference a column from B to determine the discriminator value.Also I know it would be possible to hold the TYPE column in A and B however this would mean the value is redundant in A (i want to avoid this situation).
Code:
@Entity
@Table(name="A")
@Inheritance(strategy=InheritanceType.JOINED)
@DiscriminatorColumn(
name="TYPE",
discriminatorType=DiscriminatorType.STRING
)
@ForceDiscriminator
public class A {
@ManyToOne(
fetch=FetchType.EAGER,
targetEntity=IssueTypeImpl.class,
cascade = {CascadeType.PERSIST, CascadeType.MERGE})
@JoinColumn(name="B_OID", nullable=false)
private B b;
...
}
@Entity
@Table(name="B")
public class B {
@Id
@Column(name="OID", unique=true, nullable=false, length=64)
private String oid;
@Column(name="TYPE", nullable=false, length=40)
private String type;
...
}
Thanks & Best Regards,
Walter