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