I have two classes Employee and Project, i am doing one to one relationship and it is working without property-ref please see below:
<one-to-one name="project" class="com.hibernate.practice.entitytype.Project" <!--property-ref="employee"--> cascade="save-update"> </one-to-one>
as u can see i have commented the property-ref
Other side of project (class) mapping file i have defined:
<many-to-one name="employee" class="com.hibernate.practice.entitytype.Employee" column="EMP_ID" unique="true" ></many-to-one>
now what the definition says : property-ref (optional): the name of a property of the associated class that is joined to this foreign key. If not specified, the primary key of the associated class is used.
I have not specified "property-ref" but still EMP_ID column in project table is populated with the Employee ID(primary key) i was expecting it will be populated with Project ID(primary key) as the definition says (highlighted in bold). Please explain what is wrong, when i add it or do not add this property-ref, I can't see any difference ? Why it is in hibernate? Please i am waiting for an answer.