Click here to Skip to main content
15,885,069 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Java
<hibernate-mapping>
    <class name="hibonetoonehbm.Student" table="student">
        <id name="studentId" column="StudentID" type="long">
            <generator class="native"/>
        </id>
        <property name="studentName" column="StudentName" type="string" length="50"/>
        <many-to-one name="studentAddress" column="StudentAddress" cascade="all" unique="true" not-null="true"/>
    </class>
</hibernate-mapping>

In the above code we perform one-to-one mapping using <many-to-one> by setting unique="true". There is also a <one-to-one> tag. Could anyone explain me why <many-to-one> tag is used for one-to-one mapping even if <one-to-one> tag exists ?

What I have tried:

I tried using <one-to-one> tag but there is no 'column' attribute in <one-to-one> tag :(
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900