-->
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.  [ 2 posts ] 
Author Message
 Post subject: help with join table
PostPosted: Tue Aug 09, 2005 8:55 am 
Newbie

Joined: Fri Jul 08, 2005 4:40 am
Posts: 8
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

im trying to map a many-to-many relationship between the tables LOY_ORDINE and LOY_BOLLA using the join-table LOY_BOLLA_ORDINE: the fact is that there is a field in the join table which is foreign key to both tables and my mapping (which IS correct accordind to the doc .. yes i read it) reflects the thing ..

why is not working???

Repeated column in mapping for collection: fuckthegest.model.Ordine.bolle column: C_CMP
but C_CMP is foreing key both to LOY_ORDINE and LOY_BOLLA so i HAVE to put it both in <key> and <many-to-many> inside <set name="bolle">

Hibernate version:
2.1
Mapping documents:
<hibernate-mapping>

<class name="fuckthegest.model.Ordine" table="LOY_ORDINE">

<composite-id>
<key-property name="cmp" type="string" column="C_CMP" />
<key-property name="codOrd" type="string" column="C_COD_ORD" />
<key-property name="datOrd" type="date" column="D_DAT_ORD" />
</composite-id>

<property name="stato" type="string" column="C_STA_ORD" />

<set name="bolle" table="LOY_BOLLA_ORDINE" >
<key>
<column name="C_CMP" />
<column name="C_COD_ORD" />
<column name="D_DAT_ORD" />
</key>
<many-to-many class="fuckthegest.model.Bolla" >
<column name="C_CMP" />
<column name="C_COD_BOL" />
<column name="D_DAT_BOL" />
</many-to-many>
</set>

</class>

</hibernate-mapping>



<hibernate-mapping>

<class name="fuckthegest.model.Bolla" table="LOY_BOLLA">

<composite-id>
<key-property name="cmp" type="string" column="C_CMP" />
<key-property name="codBolla" type="string" column="C_COD_BOL" />
<key-property name="datBolla" type="date" column="D_DAT_BOL" />
</composite-id>

<property name="stato" type="string" column="C_STA_BOL" />

</class>

</hibernate-mapping>

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

net.sf.hibernate.MappingException: Repeated column in mapping for collection: fuckthegest.model.Ordine.bolle column: C_CMP
at net.sf.hibernate.collection.AbstractCollectionPersister.checkColumnDuplication(AbstractCollectionPersister.java:654)
at net.sf.hibernate.collection.AbstractCollectionPersister.<init>(AbstractCollectionPersister.java:167)
at net.sf.hibernate.collection.BasicCollectionPersister.<init>(BasicCollectionPersister.java:35)
at net.sf.hibernate.persister.PersisterFactory.createCollectionPersister(PersisterFactory.java:55)
at net.sf.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:148)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:805)
at fuckthegest.model.manager.ManagePropostaOrdine.select(ManagePropostaOrdine.java:26)
at fuckthegest.web.po.PoSelectAction.execute(PoSelectAction.java:46)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 09, 2005 3:54 pm 
Expert
Expert

Joined: Thu Sep 04, 2003 8:23 am
Posts: 368
You are using the same column C_CMP to refer to both ends of your association so it is why hibernate tells you that you have a duplicate column definition.

The best way to solve this is to separate C_CMP_ORD and C_CMP_BOL as you did with the other columns. If this not fit with you database design you'll have to change your object model to ensure that you can just associate Ordine and Bolla with the same C_CMP (I am not sure this is possible)

Seb

_________________
Seb
(Please don't forget to give credits if you found this answer useful :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.