wood burning stoves 2.0*
The moose likes Object Relational Mapping and the fly likes Hibernate I18N Repeated column with composite IDs Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate I18N Repeated column with composite IDs" Watch "Hibernate I18N Repeated column with composite IDs" New topic
Author

Hibernate I18N Repeated column with composite IDs

iago moure
Greenhorn

Joined: Apr 23, 2009
Posts: 2
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

Joined: Feb 18, 2009
Posts: 13
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

Joined: Apr 23, 2009
Posts: 2
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hibernate I18N Repeated column with composite IDs
 
Similar Threads
Outer join between 3 entities in HQL
Edit primary key, if it's a foreign key
OneToOne mapping with 2 composite keys using JPA
JPA ManyToOne composite foreign key reference for optional target
How do I map composite primary key/foreign key