0

UserDetails.java

@Entity
@Table(name="userdetails")
public class UserDetails {
//@Id @GeneratedValue(strategy=GenerationType.AUTO)
@Id @Embedded
//@EmbeddedId
private int userId;
private String userName;
@Embedded
@AttributeOverrides({
@AttributeOverride(name="street",column=@Column(name="home_street_name")),
@AttributeOverride(name="city",column=@Column(name="home_city_name")),
@AttributeOverride(name="state",column=@Column(name="HOME_STATE_NAME")),
@AttributeOverride(name="pincode",column=@Column(name="HOME_PINCODE"))
})
private Address homeAddress;
@Embedded
private Address officeAddress;

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;
}
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;
}

}

Address.java

@Embeddable
public class Address {
@Column(name="street_name")
private String Street;
@Column(name="city_name")
private String city;
@Column(name="state_name")
private String state;
@Column(name="pin_code")
private String pincode;
public String getStreet() {
    return Street;
}
public void setStreet(String street) {
    Street = street;
}
public String getCity() {
    return city;
}
public void setCity(String city) {
    this.city = city;
}
public String getState() {
    return state;
}
public void setState(String state) {
    this.state = state;
}
public String getPincode() {
    return pincode;
}
public void setPincode(String pincode) {
    this.pincode = pincode;
}

}

when am running getting exception that,

Exception in thread "main" org.hibernate.MappingException: Repeated column in mapping for entity: embedded.UserDetails column: street_name (should be mapped with insert="false" update="false")
3
  • 1
    Please add the framework related tag for questions related to that specific framework. Added now. Commented Oct 31, 2014 at 7:18
  • Which part of the exception message do you not understand? Commented Oct 31, 2014 at 7:18
  • am new to hibernate. am not getting where is the duplicate coloumn Commented Oct 31, 2014 at 7:31

1 Answer 1

1

Try changing the following line in the Address class

private String Street; to private String street;

Oh, and the following didn't work on my side. I had to change the following in the UserDetails class

@Id @Embedded
//@EmbeddedId
private int userId;

to this

@Id
//@EmbeddedId
private int userId;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.