I'm trying to create an ecommerce website using spring, hibernate and for the first time following DDD.
At the moment the situation is this. I'm considering the object USER as aggregate root which has a list of addresses (previous ones.. and current) and for every address there is associated a Country (isocode, name)..
I assumed that Address and Country are Value Objects.. strictly related to the user.
In the @Entity class User there is: @ElementCollection @CollectionTable(name = "addresses", joinColumns = @JoinColumn(name = "address_id")) @OrderColumn(name="user_id") private List addresses;
In the @Embeddable class Address I would like to create a separate table for Country that I can populate during the initialization and the Address has only a foreign key.
I tried @Embeddable Country and in Address @Embedded private Country country
and also @SecondaryTable .. but this can be used only in @Entity class.. So the problem is that the fields of Country are saved inside the Address Table.
SHould I create an @Entity for Country? Or there is another way to map these class?
Thanks