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 ]
Joined: Jun 19, 2001
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.
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.
SCWCD 1.4<br />---------------------<br />Ability is what you're capable of. <br />Motivation determines what you do. <br />Attitude determines how well you do it.<br />---------------------
Joined: Mar 21, 2005
After adding insertable, updatable attributes to JoinColumn annotation, it resolved the problem.
Thank you, you guys are awesome!