I have a problem with hibernate mappings when I try to map i18n lookup tables. I have to develop an international site, so I decided to create the lookup tables with i18n inside using composite ids. Example with the table gender, with two languages (1 = English, 2= Spanish).
ID_GENDER | GENDER | ID_LANGUAGE
1 | MALE | 1
2 | FEMALE | 1
1 | HOMBRE | 2
2 | MUJER | 2
The composite id in the previous table is: ID_GENDER + ID_LANGUAGE. The purpose of this technique is quite obvious, when the customer change the language in the web, the properties AND the lookup tables content changes as well.
So I extend the idea to all my lookup tables, netbeans hibernate wizards converts each lookup tables in two pojos, i.e. TmGender and TmGenderId (with the composite id).
I mapping all my classes in hibernate.cfg.xml and everything looks perfect until this point, but when I try to used this lookup tables within a POJO with JPA annotations:
When I try to used the result is: "Initial SessionFactory creation failed.org.hibernate.MappingException: Repeated column in mapping ..."
And well yes, there is a repetition in ID_LANGUAGE but the problem is that MUST BE a repetition because the same pojo could use many lookup tables, and all of them must have this kind of many to one relationship.
I can not change the values of "insertable" and "updatable" because I need this data to be inserted.
Any help would be welcomed, I am started to do this: