Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: 3.2.4.GA
Hibernate Annotation version: 3.4.0.GA
Hi, I am trying to use Embedded Objects/Components in annotation. In the code snippet below, I am trying to save only the name of countries that I have lived in. (Not the other properties of country, like flagColor).
public class Address implements Serializable {
String city;
@Embedded
@AttributeOverrides({
@AttributeOverride(name="name", column = @Column(name="COUNTRY_NAME_1"))
})
Country country_lived_1;
@Embedded
@AttributeOverrides({
@AttributeOverride(name="name", column = @Column(name="COUNTRY_NAME_2"))
})
Country country_lived_2;
}
@Embeddable
public class Country implements Serializable {
@Column(name="countryName") private String name;
private String flagColor;
public String getName() { return name; }
public void setName(String name) { this.name = name; }
public String getFlagColor() { return flagColor; }
public void setFlagColor(String flagColor) { this.flagColor = flagColor; }
}
Error I got is :
org.hibernate.MappingException: Repeated column in mapping for entity: Address column: flagColor (should be mapped with insert="false" update="false")
It seems that all properties of country has to be defined in @AttributeOverrides, even though flagColor is not needed here.
Is there any way that only the name of the country can be retrieved from Country?
Thanks!