I wanted to bring my question to a wider audience, since we have been discussing it in our company for some time and cannot find the answer.
Suppose we have a Transaction object, which is an aggregated root. Inside the Transaction , we have Money , which is the object of value.
class Transaction {
private Money money;
}
and
class Money {
private BigDecimal amount;
private String currency;
}
Such a Transaction can be saved (we use hibernate) for db in a simple table transaction
+-----------------+
| transaction |
+-----------------+
|id : bigint |
|amount: decimal |
|currency: varchar|
|other... |
+-----------------+
And everything would be great, but ... the client requires us to have a currency table in the database (we call it dictionary tables), and each table (including a transaction) that has money should point to a currency table:
+-----------------+ +-----------------+
| transaction | |curency |
+-----------------+ +-----------------+
|id : bigint | +---> | id: bigint |
|amount: decimal | | | code: varchar |
|curr_id: bigint | ----+ | name: varchar |
|other... | +-----------------+
+-----------------+
, Money :
class Money {
private BigDecimal amount;
private Currency currency;
}
value:( ? , , , . , , , , ddd.
. , , , Country FederalState ( ). , (, Institution) , FederalState. , simpe :
class Institution {
Address address;
}
class Address {
String street;
String houseNo;
String federalState;
String country;
}
, , :
class Address {
String street;
String houseNo;
FederalState federalState;
}
, Address value.
, , od ddd?