Hi ..
I have a question about a problem that I cannot solve.
My Bean class
Code:
class Bean {
private String id =null;
private Set translations = new HashSet();
//constructor + getters + setters
}
My Translation class
Code:
class Translation {
private String title = "";
private String description = "";
private Language language = "";
// constructor + getters + setters
}
in my Bean.hbm.xml I would like to have
Code:
<set name="translations">
<key column="bean_id" not-null="true" cascade="all" />
<one-to-many class="Translation" />
</set>
in my Translation.hbm.xml i would like to have
Code:
<class name="Translation" table="bean_translation">
<id column="id" length="36" name="id" type="string" />
<many-to-one column="fk_language_id" name="language" not-null="false" /> <!-- references LANGUAGE POJO -->
<property column="title" name="title" type="string"/>
<property column="updated" name="updated" type="timestamp"/>
</class>
now to the problem.
I want to create UNIQUE KEY for language and bean id in my translation table!!! I need it cause every bean can have only 1 translation in specific language (1 english tittle and description)
Another thing I'm trying to avoid is
Code:
Translation t = new Translation().setBean(instanceOfBean); // NO WAY !!!!
so adding translation to a bean must be done like this
Code:
Bean b = new Bean().addTranslation(instanceOfTranslation); //adds translation to the set !!!
I've been strugling with this for far too long .. so any help would be appreciated !
Regards
Armando