Pessoal,
Estou usando hibernate, estou com esse erro “Repeated column in mapping for entity”, e não consigo me livrar dele, podem me ajudar?
Segue os hbm’s envolvidos:
Unidade.hbm.xml
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<hibernate-mapping>
<!--
Created by the Middlegen Hibernate plugin 2.2
http://boss.bekk.no/boss/middlegen/
http://www.hibernate.org/
-->
<class
name="Unidade"
table="unidade"
lazy="false"
>
<id
name="cdUnidade"
type="java.lang.Integer"
column="cd_unidade"
>
<generator class="increment" />
</id>
<set
name="coletas"
lazy="true"
inverse="true"
cascade="all"
>
<key>
<column name="cd_unidade"/>
</key>
<one-to-many
class="Coleta"
/>
</set>
</class>
</hibernate-mapping>
Coleta.hbm.xml:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<hibernate-mapping>
<!--
Created by the Middlegen Hibernate plugin 2.2
http://boss.bekk.no/boss/middlegen/
http://www.hibernate.org/
-->
<class
name="Coleta"
table="coleta"
lazy="false"
>
<meta attribute="extends" inherit="false">VO</meta>
<composite-id name="comp_id" class="ColetaPK">
<key-property
name="cdUnidade"
column="cd_unidade"
type="java.lang.Integer"
length="4"
/>
<key-property
name="cdColeta"
column="cd_coleta"
type="java.lang.Integer"
length="4"
/>
</composite-id>
<many-to-one
name="unidade"
class="Unidade"
update="false"
insert="false"
>
<column name="cd_unidade"/>
</many-to-one>
</class>
</hibernate-mapping>
ERRO:
org.hibernate.MappingException: Repeated column in mapping for entity: Coleta column: cd_unidade (should be mapped with insert="false" update="false")
at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:504)
at org.hibernate.mapping.PersistentClass.checkPropertyColumnDuplication(PersistentClass.java:526)
at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:544)
at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:335)
at org.hibernate.mapping.RootClass.validate(RootClass.java:188)
at org.hibernate.cfg.Configuration.validate(Configuration.java:839)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1000)
at CadastroDAO.getSessionFactory(CadastroDAO.java:170)
at CadastroDAO.loadSessionFactory(CadastroDAO.java:122)
at ThreadLoadHibernate.run(ThreadLoadHibernate.java:24)
Esses HBM’s foram gerados pelo middlegen, e mesmo assim o erro continua…
Alguma pista?
[]'s
Rufino