1

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?

hguser
  • 35,079
  • 54
  • 159
  • 293

1 Answers1

2

You should not define the fields again in child class : check this out : https://stackoverflow.com/a/5258090/286588

Community
  • 1
  • 1
Farm
  • 3,356
  • 2
  • 31
  • 32
  • Oh I am stupid, I have read the answer you posted, but I have not noticed the `we should not define id here again`. Thank you , it works now. – hguser Mar 17 '15 at 05:35