Hi, i have an abstract base class:
Code:
@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "TaxBase")
abstract public class TaxBaseImp implements RequiresResetOfCalculationData {
Now i want to ensure that a property in a subclass can't be null.
Code:
@Entity
@DiscriminatorValue("Sammelbaustein")
public class TaxBaseSammelbaustein extends TaxBaseImp {
with the attribute
Code:
@OneToOne(cascade = CascadeType.ALL)
@JoinColumn(nullable = false)
private UniversalTarifNew tarifImp;
Which cause problems wit another subclass, which doesn't have that property.
Code:
Entity
@DiscriminatorColumn(name = "TaxBalanceSheet")
public class TaxBaseBalanceSheet extends TaxBaseImp implements RequiresResetOfCalculationData {
So my question is, cause
Code:
@JoinColumn(nullable = false)
seems to be to strong, what is the right way to do that?
Code:
@OneToOne(cascade = CascadeType.ALL, optional = false)
is causing the same problems.
Is this possibly? Can I combine a discrimantor-value with a not null constraint?
But anyway, I'll probably give up the constraint or I will change the InheritanceType. I have chosen
SINGLE_TABLE cause this is the only additional attribute in all subclasses at the moment.
May be to change the InheritanceType is the better way in any case, but it would like to know how to do that or at least that it isn't possible.
Thanks a lot.
Greetings Michael