I have a class A, with property of class B.
The SQL table for A does not know anything about B.
The SQL table for B contains a foreign key to A.
How can I map (in hbm.xml) so that B is a property of A? I know how to do this with Sets:
<set name="b" table="B" cascade"all-delete-orphan">
<key column="a_id">
<composite-element class="B">
<property name="bProp" column="b_prop" type="string"/>
</composite-element>
</set>
Thing is, B is NOT a set of A. Rather just a single element. How might I go about mapping this?
Edit: To clarify a bit, my use case is similar to http://docs.jboss.org/hibernate/orm/3.6/reference/en-US/html/associations.html#assoc-unidirectional-m21 except instead of:
create table Person ( personId bigint not null primary key, addressId bigint not null )
create table Address ( addressId bigint not null primary key )
I have:
create table Person ( personId bigint not null primary key )
create table Address ( personId bigint, addressId bigint not null primary key )
However, I would expect then that the actual Address Class does not contain any references to Person:
class Person {
Address address;
}
class Address {
int id;
}