• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate I18N Repeated column with composite IDs

 
iago moure
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

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).
TM_GENDER
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:

Thank you in advance!.



 
Doug MacKenzie
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This may be of help
http://opensource.atlassian.com/projects/hibernate/browse/HHH-1338

I changed my mappings to one-to-many to get around this.
 
iago moure
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for your answer,

SO my problem is a detected bug since 3.1 version and still unresolved... Unbelievable.

Well, I tried to apply your work around suggestion, but I doesn't work to me. After converts my ManyToOne in OneToMany Hibernate says that
"Unable to find column with logical name: ID_GENDER"

Maybe I don't make the OneToMany relationship well...

Thank you anyway.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic