Reputation: 36020
I am using the @MappedSuperclass
in my hibernate project:
@MappedSuperclass
public abstract class AbstractHotel extends AbstractData {
protected String id;
protected String name;
protected String type;
....
}
@Entity
@Table(name = "T_HOTEL")
public class Hotel extends AbstractHotel {
@AttributeOverride(name = "id", column = @Column(name = "hotel_id"))
protected String id;
@AttributeOverride(name = "name", column = @Column(name = "hotel_name"))
protected String name;
@AttributeOverride(name = "type", column = @Column(name = "hotel_type"))
protected String type;
...
}
As shown, I want the column can be overrideed in the subclass, however I get the error:
org.hibernate.MappingException: Duplicate property mapping of id found in cn.test.Hotel
Is it possible to fix this?
Upvotes: 1
Views: 1052
Reputation: 3396
You should not define the fields again in child class : check this out : https://stackoverflow.com/a/5258090/286588
Upvotes: 2