我的数据模型代表法律实体,例如商业或个人.两者都是纳税实体,并且都有一个TaxID,电话号码的集合,和邮寄地址的集合.
我有一个Java模型,有两个扩展抽象类的具体类.抽象类具有两个具体类共有的属性和集合.
AbstractLegalEntity ConcreteBusinessEntity ConcretePersonEntity
------------------- ---------------------- --------------------
Set<Phone> phones String name String first
Set<Address> addresses BusinessType type String last
String taxId String middle
Address Phone
------- -----
AbsractLegalEntity owner AbstractLegalEntity owner
String street1 String number
String street2
String city
String state
String zip
Run Code Online (Sandbox Code Playgroud)
我在MySQL数据库上使用Hibernate JPA Annotations,其类如下所示:
@MappedSuperclass
public abstract class AbstractLegalEntity {
private Long id; // Getter annotated with @Id @Generated
private Set<Phone> phones = new HashSet<Phone>(); // @OneToMany
private Set<Address> address = new HashSet<Address>(); …Run Code Online (Sandbox Code Playgroud)