Null values
Our current mapping strategy limits our means to specify data
integrity constraints. It is no longer possible to disallow
null
values for properties belonging to derived
classes. We might want to disallow null
values in the
bankName
property. Hibernate will generate a
corresponding database attribute ❶:
Java |
|
Sql |
|
Looks good? Unfortunately the attempt to save a bank account ❶ yields a runtime exception ❶:
Java |
|
Sql |
|
Conclusion: A table per class hierarchy mapping does not allow to specify not null constraints for properties of derived classes.
No. 21
Mapping figures
Q: |
Map the following model to a database: Figure 945. Figure subclasses
Todo: Ref/Fig/figureInherit.fig The two properties The abstract method |
A: |
The main difference to the current
|