I want to create a class (which maps to a table in a MySQL databse) in java and it has the following members:
id (int)
policyNumber (string)
cost (double)
beneficiaries (list of Beneficiary objects)
And the Beneficiary
class has the following members:
name (string)
gender (enum with Male or Female as possible values)
dateOfBirth (Date)
How would I create a column in my table that would represent a list of Beneficiary
objects?
I would suggest adding a field to Beneficiary
table/class that maps to the id
of the previous one (eg policy_id
)
(or use a mapping table if it's a many-to-many relationship)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.