Lets we will using the Collection for that.
1. In this code snip User has one address
2. In this code snip User has two addresses
3. In this code snip User has more than two addresses
In third case how to manage the records about addresses for that user, now for managing this type of problems we have to use the collection, we do not need to care about how many of the addresses user have. Lets see there are same change in the code for that…
We look following example of Object of Entity Type:
Fields (including property get methods)Defines a collection of instances of a basic type or embeddable class. Must be specified if the collection is to be mapped by means of a collection table.
hibernate.cfg.xml will be the same as the previous chapter.
In the second table first column TBL_USERS_DETAILS_USER_ID has the user id is foreign key for this table and primary key of the TBL_USER_DETAILS table.