Reputation: 747
I have Address
and Organization
tables. Address
has FK named organizationID
.
Address
class has following property:
Organization organization;
Organization
class has following property:
Address address property;
Mapping for Address
:
<one-to-one name="organization" class="entity3.Organization"
constrained="true">
</one-to-one>
How can I specify FK column organizationID
? If I put
<column name="OrganizationID" not-null="true"/>
between one-to-one tags I get XML parse error.
Upvotes: 1
Views: 2648
Reputation: 40176
Try using property-ref
property, like this:-
<one-to-one name="organization" class="entity3.Organization" property-ref="OrganizationID" constrained="true"/>
Upvotes: 2
Reputation: 21
You use "property-ref" on the mapping to specify the property of the other class to join to the primary key.
http://docs.jboss.org/hibernate/core/3.3/reference/en/html/mapping.html#mapping-declaration-onetoone
Upvotes: 2