I'm having troubles getting an object through a cross table.
I have 3 tables: countries, languages, countryNames.
countries and languages just have a PK.
countryNames has a country, language, and a name.
I can get the countryName by using "WHERE country = 'countryId' AND language = 'languageId'".
But when I try countryName.getCountry it returns null. The same goes for language, but getName does work. So I quess it's a problem in my mapping file from countryName.
Here are the 3 mapping files:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="data.Country" table="countries">
<id name="id" column="id" length="20">
<generator class="assigned" />
</id>
</class>
</hibernate-mapping>
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="data.Language" table="languages">
<id name="id" column="id" length="10">
<generator class="assigned" />
</id>
<property name="active">
<column name="active" not-null="true" />
</property>
</class>
</hibernate-mapping>
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="data.CountryName" table="countryNames">
<composite-id name="countryNameFK" class="data.CountryNameFK">
<key-many-to-one name="country" class="data.Country" column="country" />
<key-many-to-one name="language" class="data.Language" column="language" />
</composite-id>
<property name="name">
<column name="name" length="50" not-null="true" />
</property>
</class>
</hibernate-mapping>
I suspect I do something wrong in the <composite-id>.
Can someone tell me how it should be?