I want a one to one mapping with employee and parking space. i first create a parking space and then create a employee by passing the parking space object to it. i set the parking space by
emp.setParkingSpace(ps);
where ps is the parking space object.
i hoped that the id of parking space will be stored in the employee table. But it was not the case. i had all the other details of the employee excpet the parking space id.
When i used many to one mapping instead of one to one mapping like this
<many-to-one name="parkingSpace" class="com.sample.employee.ParkingSapce" column="PARKING_SPACE_ID" unique="true" />
i was able to get the parking space id in the employee table, but the problem is, the same parking space id was persisted with more than one employee, which is not what i want.
I hope i have made myself clear.
Any help in this issue would be much appreciated.
Thanks in advance.
Balaji
|