Retrieving Objects
On the database server side object retrieval results in a more
expensive operation: A query for root class instances
ofinherit.joined.v1.BillingDetails
❶ of our inheritance hierarchy
results in joining all three tables BillingDetails
❶, BankAccount
❷ and CreditCard
❸:
Java | package inherit.joined.v1;
...
public class RetrieveAll {
...
final Query searchBilling = session.createQuery("from inherit.tpc.v1.BillingDetails" ❶);
... |
Sql | Hibernate: select billingdet0_.id as id0_, billingdet0_.created as created0_, billingdet0_.number as number0_, billingdet0_1_.bankName as bankName1_, billingdet0_1_.swiftcode as swiftcode1_, billingdet0_2_.cardType as cardType2_, billingdet0_2_.expiration as expiration2_, case when billingdet0_1_.id is not null then 1 when billingdet0_2_.id is not null then 2 when billingdet0_.id is not null then 0 end as clazz_ from BillingDetails billingdet0_ ❶ left outer join BankAccount billingdet0_1_ ❷ on billingdet0_.id=billingdet0_1_.id left outer join CreditCard billingdet0_2_ ❸ on billingdet0_.id=billingdet0_2_.id |
No. 22
JPA constraints and database integrity.
Q: |
Explain all integrity constraints of the Hibernate generated schema. Will it implement the constraints corectly on database level corresponding to the inheritance related Java™ objects? On contrary: Are there possible database states which do not correspond to the domain model's object constraints? |
A: |
No. 23
Implementing figures by joined subclasses
Q: |
Implement the model being given in Figure 951, “Figure subclasses” by joined subclasses. |
A: |