I am sorry. But I still have problem.
Let's me explain :
I have Countries table
table Countries {
int id;
int name;
}
that has e.g. two entries
Countries.id = 1
Countries.name = 'USA'
Countries.id = 2
Countries.name = 'Japan'
Also I have Addresses table :
table Addresses {
int id;
int countryId;
}
Also I have JavaBeans
class Country {
int id;
String name;
}
class Address {
int id;
Country country;
}
I develop .hbm :
<hibernate-mapping>
<class name="Country" table="Countries">
<id name="id" column="id" unsaved-value="null">
<generator class="increment"/>
</id>
<property name="name" column="name" not-null="true"/>
</class>
<class name="Address" table="Addresses">
<id name="id" column="id" unsaved-value="null">
<generator class="increment"/>
</id>
<???-to-??? name="country" class="Country" column="countryId" />
</many-to-one>
</class>
</hibernate-mapping>
Which association should I use here? many-to-one or one-to-one or something else ?
Could you please give me example?
Also I have the following data in Addresses table
Addresses.id = 1
Addresses.countryId=1
Addresses.id = 2
Addresses.countryId=2
Addresses.id = 1
Addresses.countryId=2
Thanks,
Aritomo
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
Mapping documents:
Code between sessionFactory.openSession() and session.close():
Full stack trace of any exception that occurs:
Name and version of the database you are using:
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:
Problems with Session and transaction handling?
Read this:
http://hibernate.org/42.html