-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 posts ] 
Author Message
 Post subject: URGENT-Repeated column map error
PostPosted: Tue Aug 12, 2008 3:26 pm 
Beginner
Beginner

Joined: Thu Oct 25, 2007 1:21 pm
Posts: 29
I am getting the below mentioned error when i am declaring a property as well as an association mapped to the same column 'a'. Any ideas on how i can resolve the issue. Thanks for help.


org.hibernate.MappingException: Repeated column in mapping for collection: xList column: a
at org.hibernate.mapping.Collection.checkColumnDuplication(Collection.java:304)
at org.hibernate.mapping.Collection.checkColumnDuplication(Collection.java:327)
at org.hibernate.mapping.Collection.validate(Collection.java:284)
at org.hibernate.mapping.IndexedCollection.validate(IndexedCollection.java:67)
at org.hibernate.cfg.Configuration.validate(Configuration.java:1030)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1211)





<list name="xList"
lazy="true"
access="field"
cascade="save-update"
outer-join="false"
table="x">
<key column="x" not-null="true" unique="false"/>
<index column="y"/>
<composite-element class="CompClass">
<property name="z" column="z" type="timestamp" not-null="true" access="field"/>
<property name="aId" column="a" type="long" not-null="true" insert="true" update="true"/>
<many-to-one name="a"
column="a"
class="AClass"
access="field"
insert="false" update="false"
lazy="proxy"
/>
</composite-element>
</list>


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 12, 2008 4:23 pm 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
Does it help if you map the "a" column as a formula in either the <property> or <many-to-one>?

Code:
<property name="aId" formula="a" ... >
[/quote]


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 12, 2008 4:43 pm 
Beginner
Beginner

Joined: Thu Oct 25, 2007 1:21 pm
Posts: 29
thanks for the quick response.

actually i wanted to do saving by setting aId only and would like to retrieve by 'a'.

what is the purpose of formula? what is going to do?

so am i supposed to put formula on the property or many-to-one?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 12, 2008 4:53 pm 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
Quote:
what is the purpose of formula?


From Hibernate documentation at http://www.hibernate.org/hib_docs/v3/re ... n-property:

Quote:
formula (optional): an SQL expression that defines the value for a computed property. Computed properties do not have a column mapping of their own.


I think this could be used to get rid of the "Repeated column mapping", though I have never had use for it myself. Try it and post a message telling us if it worked or not.

Quote:
so am i supposed to put formula on the property or many-to-one?


<many-to-one> since that is the one you have insert="false" and update="false"


Top
 Profile  
 
 Post subject: errors
PostPosted: Tue Aug 12, 2008 5:12 pm 
Beginner
Beginner

Joined: Thu Oct 25, 2007 1:21 pm
Posts: 29
java.lang.NullPointerException
at org.hibernate.util.StringHelper.qualify(StringHelper.java:264)
at org.hibernate.util.StringHelper.qualify(StringHelper.java:278)
at org.hibernate.loader.JoinWalker.walkCompositeElementTree(JoinWalker.java:499)
at org.hibernate.loader.JoinWalker.walkCollectionTree(JoinWalker.java:310)
at org.hibernate.loader.JoinWalker.walkCollectionTree(JoinWalker.java:255)
at org.hibernate.loader.collection.BasicCollectionJoinWalker.<init>(BasicCollectionJoinWalker.java:47)
at org.hibernate.loader.collection.BasicCollectionLoader.<init>(BasicCollectionLoader.java:53)
at org.hibernate.loader.collection.BasicCollectionLoader.<init>(BasicCollectionLoader.java:40)
at org.hibernate.loader.collection.BatchingCollectionInitializer.createBatchingCollectionInitializer(BatchingCollectionInitializer.java:87)
at org.hibernate.persister.collection.BasicCollectionPersister.createCollectionInitializer(BasicCollectionPersister.java:297)
at org.hibernate.persister.collection.AbstractCollectionPersister.postInstantiate(AbstractCollectionPersister.java:541)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:294)


Top
 Profile  
 
 Post subject: errors
PostPosted: Tue Aug 12, 2008 5:13 pm 
Beginner
Beginner

Joined: Thu Oct 25, 2007 1:21 pm
Posts: 29
i am getting these errors, when i put it on many-to-one


java.lang.NullPointerException
at org.hibernate.util.StringHelper.qualify(StringHelper.java:264)
at org.hibernate.util.StringHelper.qualify(StringHelper.java:278)
at org.hibernate.loader.JoinWalker.walkCompositeElementTree(JoinWalker.java:499)
at org.hibernate.loader.JoinWalker.walkCollectionTree(JoinWalker.java:310)
at org.hibernate.loader.JoinWalker.walkCollectionTree(JoinWalker.java:255)
at org.hibernate.loader.collection.BasicCollectionJoinWalker.<init>(BasicCollectionJoinWalker.java:47)
at org.hibernate.loader.collection.BasicCollectionLoader.<init>(BasicCollectionLoader.java:53)
at org.hibernate.loader.collection.BasicCollectionLoader.<init>(BasicCollectionLoader.java:40)
at org.hibernate.loader.collection.BatchingCollectionInitializer.createBatchingCollectionInitializer(BatchingCollectionInitializer.java:87)
at org.hibernate.persister.collection.BasicCollectionPersister.createCollectionInitializer(BasicCollectionPersister.java:297)
at org.hibernate.persister.collection.AbstractCollectionPersister.postInstantiate(AbstractCollectionPersister.java:541)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:294)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 13, 2008 9:07 am 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
I just tested this with a plain <many-to-one> association and it worked fine. It could be that there are some issues/bugs when the <many-to-one> is within a <list> and a <composite-element>. I am not able to check this since I don't think I have any association like that.

Why do you need the duplicate mapping?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 13, 2008 11:17 am 
Beginner
Beginner

Joined: Thu Oct 25, 2007 1:21 pm
Posts: 29
Hi,

thanks a lot for your reply.

it was working fine with just a plain one; i am only seeing the seeing the issue with composite-element.

actually we do not need both, let me see if i can fix it without having both.



thanks


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.