-->
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.  [ 4 posts ] 
Author Message
 Post subject: Repeated column in mapping for collection (Many-to-Many)
PostPosted: Wed Feb 13, 2008 10:56 am 
Newbie

Joined: Wed Feb 13, 2008 10:28 am
Posts: 5
Hi folks...

I´m trying to map a many-to-many relation beetween two tables. Beetwen this two tables exists one link table.
Theese two tables have a composite key with one column in common, called 'cod_orgao'.
The problem is that when I try to map the relation, hibernate throws the follow exception, saying that exists one repeated column.

Code:
org.hibernate.MappingException: Repeated column in mapping for collection: br.com.dsystems.ds001.models.TituloRec.faturaDuplicatas column: cod_orgao
   at org.hibernate.mapping.Collection.checkColumnDuplication(Collection.java:290)
   at org.hibernate.mapping.Collection.checkColumnDuplication(Collection.java:313)
   at org.hibernate.mapping.Collection.validate(Collection.java:270)
   at org.hibernate.mapping.Set.validate(Set.java:19)
   at org.hibernate.cfg.Configuration.validate(Configuration.java:988)
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1169)
   at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:804)
   at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:744)
   at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:131)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1118)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1085)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:429)
   at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:250)
   at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:141)
   at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:247)
   at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:161)
   at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:270)
   at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:346)
   at org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.refresh(AbstractRefreshableWebApplicationContext.java:156)
   at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:246)
   at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:184)
   at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)
   at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3763)
   at org.apache.catalina.core.StandardContext.start(StandardContext.java:4211)
   at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:759)
   at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:739)
   at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:524)
   at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:904)
   at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:867)
   at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:474)
   at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1122)
   at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:310)
   at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
   at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1021)
   at org.apache.catalina.core.StandardHost.start(StandardHost.java:718)
   at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1013)
   at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442)
   at org.apache.catalina.core.StandardService.start(StandardService.java:450)
   at org.apache.catalina.core.StandardServer.start(StandardServer.java:709)
   at org.apache.catalina.startup.Catalina.start(Catalina.java:551)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:585)
   at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:294)
   at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:432)


My map file is as follows.

Code:
<hibernate-mapping>
    <class name="br.com.dsystems.ds001.models.TituloRec" table="titulo_rec" schema="public">
        <composite-id name="id" class="br.com.dsystems.ds001.models.TituloRecId">
            <key-property name="codOrgao" type="string">
                <column name="cod_orgao" length="12" />
            </key-property>
            <key-property name="numAnoRecebe" type="java.lang.Short">
                <column name="num_ano_recebe" precision="4" scale="0" />
            </key-property>
            <key-property name="numTituloRecebe" type="java.lang.Integer">
                <column name="num_titulo_recebe" precision="7" scale="0" />
            </key-property>
        </composite-id>
        <many-to-one name="tipoTitulo" class="br.com.dsystems.ds001.models.TipoTitulo" fetch="select">
            <column name="cod_tipo_titulo" precision="7" scale="0" not-null="true" />
        </many-to-one>

        <property name="codClient" type="java.lang.Integer">
            <column name="cod_client" precision="7" scale="0" />
        </property>
        .....
        <property name="valRefereMoedaEstran" type="big_decimal">
            <column name="val_refere_moeda_estran" precision="15" />
        </property>

        <set name="faturaDuplicatas" inverse="true" table="rel_fatura_dup_titulo_rec">
            <key>
                [b]<column name="cod_orgao" length="12" not-null="true" />[/b]
                <column name="num_ano_recebe" precision="4" scale="0" not-null="true" />
                <column name="num_titulo_recebe" precision="7" scale="0" not-null="true" />
            </key>
            <many-to-many entity-name="br.com.dsystems.ds001.models.FaturaDuplicata">
                [b]<column name="cod_orgao" length="12" not-null="true" />[/b]
                <column name="num_ano_fatura" precision="4" scale="0" not-null="true" />
                <column name="num_fatura" precision="7" scale="0" not-null="true" />
                <column name="num_duplic" precision="7" scale="0" not-null="true" />
            </many-to-many>
        </set>
        <set name="tituloRecParcelas" inverse="true">
            <key>
                <column name="cod_orgao" length="12" not-null="true" />
                <column name="num_ano_recebe" precision="4" scale="0" not-null="true" />
                <column name="num_titulo_recebe" precision="7" scale="0" not-null="true" />
            </key>
            <one-to-many class="br.com.dsystems.ds001.models.TituloRecParcela" />
        </set>
    </class>
</hibernate-mapping>


The lines in bold are the problem...

Anyone here already get this error ?
I´m trying to solve this to almost one week with no success =/

Thanks in advance...
Waiting an answer...

Rodrigo Kerkhoff


Top
 Profile  
 
 Post subject: Any luck?
PostPosted: Tue Feb 26, 2008 5:07 pm 
Newbie

Joined: Mon Feb 25, 2008 10:26 am
Posts: 2
I am having the exact same problem as you with respect to the column mapping error error in Hibernate.

I was just wondering if you had managed to find a solution or at least a workaround to the problem since your last post?

All the best,


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 28, 2008 6:19 pm 
Newbie

Joined: Mon Mar 12, 2007 8:47 pm
Posts: 5
your situation its something like this case

23.4.3. Many-to-many with shared composite key attribute
http://www.hibernate.org/hib_docs/v3/reference/en/html/example-mappings.html#example-mappings-composite-key-manytomany

regards


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 28, 2008 7:56 pm 
Newbie

Joined: Thu Jan 04, 2007 1:36 pm
Posts: 16
just add insert="false" and update="false" on the property within the set mapping. That should do it.

- Arun


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