• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Hibernate I18N Repeated column with composite IDs

 
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!.



 
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.
 
Your mother is a hamster and your father smells of tiny ads!
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic