hello everyone,
I need advices about the imaginary scenario below;
Table Person : PID, HotelID
Table Hotel: HID, Name, Location
Class Person : Long PID, Hotel hotel
Class Hotel : Long HID, String name....
HotelID is the foreign key references Hotel ID in Person
The relation is : each person stays in one hotel. (one-to-one)
hotel can have many person or "no person"
So, the Hotel table holds no reference to the Person table.
I mapped them as (Dont consider syntax mismatches)
<class name= Person.............
<id name = PID .....
<one-to-one name = "hotel" class= "Hotel">
</class>
<class name = "Hotel........
<id name = HID........
<property ....
</class>
But, as you see it is wrong, this one to one relation constructs person.PID = hotel.HID but I want it to generate person.HID = hotel.HID..
Is it possible to use one-to-one,many to one associations on that scenario
or not?
I mean can I tell hibernate this:
Join these 2 tables on "that" columns not pk columns with one-to-one?
(person.HotelID = Hotel.HID)
Note: I can't change the db schema and I can't write Sql queries. I want all thing to happen in mapping file
_________________ -developer
|