Wednesday, April 4, 2012

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


 org.hibernate.MappingException: Repeated column in mapping for entity: model.User column: ID (should be mapped with insert="false" update="false")
at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:676)
at org.hibernate.mapping.PersistentClass.checkPropertyColumnDuplication(PersistentClass.java:698)
at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:720)
at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:474)
at org.hibernate.mapping.RootClass.validate(RootClass.java:235)
at org.hibernate.cfg.Configuration.validate(Configuration.java:1362)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1865)
at util.SessionUtil.<clinit>(SessionUtil.java:10)
... 1 more

Reason:

The annotation @Column name property is given the same value for two fields.


@Column(name = "ID")
private String id;

@Column(name = "ID")
private String name;

Solution:

Provide unique name for the column name.

@Column(name = "ID")
private String id;

@Column(name = "NAME")
private String name;

No comments:

Post a Comment