Component Mapping

In component mapping, we will outline dependent object as a component . A component is an object that is put away as an esteem instead of element reference. This is chiefly utilized if the needy object doen't have essential key. It is utilized if there should be an occurrence of structure (HAS-A connection), that is the reason it is named as component . How about we see the class that have HAS-A relationship.

  1. package com.javacodegeeks;  
  2.   
  3. public class Address {  
  4. private String city,country;  
  5. private int pincode;  
  6.   
  7. //getters and setters  
  8. }  
  1. package com.javacodegeeks;  
  2. public class Employee {  
  3. private int id;  
  4. private String name;  
  5. private Address address;//HAS-A  
  6.   
  7. //getters and setters  
  8. }  
Here, address is a needy object. Hibernate framework gives the office to outline dependent item as a component . We should perceive how might we map this needy object in mapping record.





javacodegeeks is optimized for learning.© javacodegeeks .
All Right Reserved and you agree to have read and accepted our term and condition