Monday, February 24, 2014

Resolved Error: org.hibernate.MappingException: Repeated column in mapping for entity

Removed
When creating a JPA project, I have created my entities using eclipse and Hibernate tools, See this link.When deploying my application on JBoss server, I had this error:

 org.hibernate.MappingException: Repeated column in mapping for entity: org.qmic.mdd.enterprise.model.MddRelationTableOneTableTwo column: person_id (should be mapped with insert="false" update="false")
at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:696)
at org.hibernate.mapping.PersistentClass.checkPropertyColumnDuplication(PersistentClass.java:718)
at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:740)
at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:493)
at org.hibernate.mapping.RootClass.validate(RootClass.java:270)
at org.hibernate.cfg.Configuration.validate(Configuration.java:1324)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1786)
at org.hibernate.ejb.EntityManagerFactoryImpl.(EntityManagerFactoryImpl.java:96)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:914)


In fact, in some association table I use a Composite Primary Key. As the association table should only use these keys, the association with these keys should be set to insert=false and update=false. It is not of the relation class to modify these attributes.

@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="person_id", insertable=false, updatable=false)

So adding these properties, the problem is resolved.


4 comments :

Articles les plus consultés