mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-16 16:15:06 +00:00
added working design doc on attribute ordering wrt inheritance
This commit is contained in:
parent
a9ee082128
commit
ccfa8101c1
35
design/working/attributes.adoc
Normal file
35
design/working/attributes.adoc
Normal file
@ -0,0 +1,35 @@
|
||||
= Attributes (and inheritance)
|
||||
|
||||
|
||||
[source]
|
||||
----
|
||||
class Customer {
|
||||
Integer id;
|
||||
String name;
|
||||
Address address;
|
||||
int quota;
|
||||
}
|
||||
|
||||
class DomesticCustomer extends Customer {
|
||||
String taxId;
|
||||
String attr1;
|
||||
String attr2;
|
||||
}
|
||||
|
||||
class ForeignCustomer extends Customer {
|
||||
String vat;
|
||||
String attr3;
|
||||
String attr4;
|
||||
}
|
||||
----
|
||||
|
||||
The general idea is that the attributes are ordered alphabetically, super attributes first. Subtypes are sorted
|
||||
depth-first and the attributes are sorted alphabetically within each sub-type. So the order of the attributes
|
||||
depends on where we start.
|
||||
|
||||
Starting from Customer we have: `[address, name, quota, attr1, attr2, taxId, attr3, attr4, vat]`
|
||||
Starting from DomesticCustomer we have: `[address, name, quota, attr1, attr2]`
|
||||
Starting from ForeignCustomer we have: `[address, name, quota, attr3, attr4, vat]`
|
||||
|
||||
This is why we cannot really have the position be an inherent part of the attribute itself - it changes depending on
|
||||
where we start.
|
Loading…
x
Reference in New Issue
Block a user