• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Hibernate Repeated column mapping problem

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi, I'm new to Hibernate, and I'm running into a bit of problem when specifying my mappings.

Currently I have a UserBean class:

and my UserBean mapping file looks like:


my RankingBean class looks like:

and RankingBean's mapping file is:


so, the error i'm getting says :

INFO - Reading mappings from resource: com/uwa/beans/UserBean.hbm.xml
INFO - Mapping class: com.uwa.beans.UserBean -> tblUser
INFO - Mapping collection: com.uwa.beans.UserBean.events -> tblParticipate
INFO - Configured SessionFactory: null
INFO - Mapping collection: com.uwa.beans.UserBean.loans -> tblLoan
INFO - Mapping collection: com.uwa.beans.UserBean.rankings -> tblRanking
org.hibernate.MappingException: Repeated column in mapping for entity: com.uwa.beans.RankingBean column: userID (should be mapped with insert="false" update="false")
at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:605)
...


I'm wondering if someone could tell me what the error is, because I seem to already have duplicated column="userID" in the events and loans collection mapping and it didn't complain there? thanks

[ October 30, 2006: Message edited by: Vince Lee ]

[Edited to include code tags - Paul Sturrock]
[ October 30, 2006: Message edited by: Paul Sturrock ]
 
Ranch Hand
Posts: 547
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Parsing of the config files stops after the first error is encountered. If you fix the first problem then hibernate will complain about the next error (if there are more).

- for the events/loans/rankins collections hibernate will create a column named "userId" in the events/loans/rankins tables, not in the user table. so there is no problem with duplicated columns in the user table
- it looks like the problem occur because your FK to user is also part of the PK in the rankins table
- (if not required then) do not use a composite key, use a surrogate key. easier to manage, map, code, query and so on.


pascal
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"userID (should be mapped with insert="false" update="false")"

This is related to mapping relationships. Just add the above(insert="false" update="false") to your userID mapping, and that should get it to work.

Mark
 
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm also having this problem.
And when I try to add these attributes to the JoinColumn annotation in my JPA POJO, I get error that these are not valid attributes of JoinColumn annotation.
I'm going to try the insertable, and updatable attributes and see if that helps.
Mean while if anyone has any pointers, please share.
 
Anand Wadhwani
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey there!
After adding insertable, updatable attributes to JoinColumn annotation, it resolved the problem.
Thank you, you guys are awesome!
 
Yeah, but does being a ninja come with a dental plan? And what about this tiny ad?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic