I am new to Hibernate . I am getting the below exception while executing. Can anyone please help to resolve the problem
Here is the hbm file:
package org.java.dto; import javax.persistence.Embedded; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Table; import javax.persistence.AttributeOverrides; import javax.persistence.AttributeOverride; import javax.persistence.Column;
@Entity @Table(name="USER_DETAILS") public class UserDetails { @Id @GeneratedValue(strategy=GenerationType.AUTO) private int userId; private String userName;
@Embedded @AttributeOverrides({ @AttributeOverride (name="street",column=@Column(name="HOME_STREET_NAME")), @AttributeOverride (name="city",column=@Column(name="HOME_NAME_CITY")), @AttributeOverride (name="state",column=@Column(name="HOME_STATE_NAME")), @AttributeOverride (name="pincode",column=@Column(name="HOME_PIN_CODE")) }) public Address getHomeAddress() { return homeAddress; } public void setHomeAddress(Address homeAddress) { this.homeAddress = homeAddress; } public Address getOfficeAddress() { return officeAddress; } public void setOfficeAddress(Address officeAddress) { this.officeAddress = officeAddress; } private Address homeAddress; @Embedded private Address officeAddress; public int getUserId() { return userId; } public void setUserId(int userId) { this.userId = userId; } public String getUserName() { return userName ; } public void setUserName(String userName) { this.userName = userName; }
}
Error is as follows:
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details. Exception in thread "main" org.hibernate.MappingException: Repeated column in mapping for entity: org.java.dto.UserDetails column: CITY_NAME (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.checkPropertyColumnDuplication(PersistentClass.java:694) 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 org.kavya.hibernate.HibernateTest.main(HibernateTest.java:41)
Thanks in advance!!!
|