Thread: Hibernate error
View Single Post
  #1 (permalink)  
Old 05-10-2007, 06:04 PM
Marty Marty is offline
Member
 
Join Date: May 2007
Posts: 38
Marty is on a distinguished road
Hibernate error
Hi everybody. I want to know if someone can help me with this problem:
I am trying to map in hibernate, and when I try to execute mi application it returns me an error in a hbm.xml file.
I check hibernate in action, links, and so on but I canīt resolve this.

Caused by: org.hibernate.MappingException: Repeated column in mapping for entity: ar.com.lmi.pojos.Empresacolumn: Emp_Cod (should be mapped with insert="false" update="false")
Code:
the 2 tables that I try to map are: CREATE TABLE AREA ( Area_Cod int NOT NULL, Area_Nivel int NOT NULL, Area_Desc varchar(50) NULL, Emp_Cod int NOT NULL ) go ALTER TABLE AREA ADD PRIMARY KEY (Area_Cod, Area_Nivel, Emp_Cod) go ALTER TABLE AREA ADD FOREIGN KEY (Emp_Cod) REFERENCES EMPRESA go CREATE TABLE EMPRESA ( Emp_Cod int NOT NULL, Emp_Desc varchar(30) NULL, Emp_CUIT varchar(13) NULL, Emp_Calle varchar(30) NULL, Emp_Nro varchar(5) NULL, Emp_Piso varchar(3) NULL, Emp_Depto varchar(3) NULL, Emp_Localidad varchar(30) NULL, Emp_CP varchar(8) NULL, Emp_Telefono varchar(11) NULL, Emp_ActDGI varchar(8) NULL, Emp_Actividad varchar(30) NULL, Emp_FirmAnsses varchar(50) NULL, Pcia_Cod int NULL ) go ALTER TABLE EMPRESA ADD PRIMARY KEY (Emp_Cod) The xbm.xml are: <hibernate-mapping package="ar.com.lmi.pojos"> <class name="Area" table="AREA"> <composite-id name="areaId" class="AreaId"> <key-property name="area_Cod" column="Area_Cod"/> <key-property name="area_Nivel" column="Area_Nivel"/> <key-property name="emp_Cod" column="Emp_Cod"/> </composite-id> <property name="area_Desc" column="Area_Desc" type="string" not-null="false"/> <many-to-one name="emp_Cod" class="Empresa" column="Emp_Cod" update="false" insert="false"/> </class> </hibernate-mapping> <hibernate-mapping package="ar.com.lmi.pojos"> <class name="Empresa" table="EMPRESA"> <id name="emp_Cod" column="Emp_Cod" type="int"> <generator class="identity"/> </id> <property name="emp_Desc" column="Emp_Desc" type="string" not-null="false"/> <property name="emp_CUIT" column="Emp_CUIT" type="string" not-null="false"/> <property name="emp_Calle" column="Emp_Calle" type="string" not-null="false"/> <property name="emp_Nro" column="Emp_Nro" type="string" not-null="false"/> <property name="emp_Piso" column="Emp_Piso" type="string" not-null="false"/> <property name="emp_Depto" column="Emp_Depto" type="string" not-null="false"/> <property name="emp_Localidad" column="Emp_Localidad" type="string" not-null="false"/> <property name="emp_CP" column="Emp_CP" type="string" not-null="false"/> <property name="emp_Telefono" column="Emp_Telefono" type="string" not-null="false"/> <property name="emp_ActDGI" column="Emp_Cod" type="string" not-null="false"/> <property name="emp_Actividad" column="Emp_Actividad" type="string" not-null="false"/> <property name="emp_FirmAnsses" column="Emp_FirmAnsses" type="string" not-null="false"/> <property name="pcia_Cod" column="Pcia_Cod" type="int" not-null="false"/> <set name="areas" table="AREA" inverse="true" cascade="all-delete-orphan"> <key column="Emp_Cod"/> <one-to-many class="Area"/> </set> </class> </hibernate-mapping> pojos: public class Area implements Serializable { private String area_Desc; /** * Constructor */ public Area() {} //Setters y getters } public class AreaId implements Serializable { private Integer area_Cod; private Integer area_Nivel; private Empresa emp_Cod; /** * Constructor */ public AreaId(Integer area_Cod, Integer area_Nivel, Empresa emp_Cod) { this.area_Cod = area_Cod; this.area_Nivel = area_Nivel; this.emp_Cod = emp_Cod; } //Setters y getters } public class Empresa implements Serializable { private Integer emp_Cod; private String emp_Desc; private String emp_CUIT; private String emp_Calle; private String emp_Nro; private String emp_Piso; private String emp_Depto; private String emp_Localidad; private String emp_CP; private String emp_Telefono; private String emp_ActDGI; private String emp_Actividad; private String emp_FirmAnsses; private Integer pcia_Cod; private Set areas = new HashSet(); /** * Constructor */ public Empresa() {} //Setters y getters }
Reply With Quote
Sponsored Links