Hi,
I want to create a simple 1-to-n relation, which is not bidirectional. So I want to be able to the get the 1-side from the n-side, but not the other way round. As an example, I have a table of countries, and a table of addresses. Each address references a country. I want to easily access the country information from an address object. But I never need all addresses for a given country.
In fact, I want to reference the same country table from several different places (say from addresses, persons, products, ...).
When I create a simple many-to-one mapping in address:
...
<many-to-one name="country" class="Country" not-null="true"/>
...
but no corresponding <set> entry in country, I get an exception like then when trying to create the database schema:
org.hibernate.MappingException: An association from the table address refers to an unmapped class: Country
I am sure that what I want to achieve is very simple, but I just can not find the correct way to do it. Can someone please give me a hint where to look for a solution?
Thanks a lot,
Christoph Jäger
Hibernate version: Hibernate 3.0
|