Reputation: 3177
I have a MappedSuperclass
@MappedSuperclass
public class A{
.
.
.
@Column(name="something")
public getSomething(){..};
public setSomething(){..};
}
I want to override the something
in a subclass
@Entity
public class B{
@Override
public getSomething(){..};
}
but getting Caused by: org.hibernate.MappingException: Duplicate property mapping of data found
Exception
I tried different things like "@AttributeOverride" annotation, but it didn't help.
The only solution i know is to make something
Transient in the mappedSuperclass. But i don't want that it will be transient here (because there is another subclasses that don't want to override something
but want that it will be transient)
Upvotes: 3
Views: 1544
Reputation: 1382
Two solutions occur to me: one is to maybe break this SuperClass up and use Emmbeddeds to create the hierarchy you want. If you want to stick with this approach though, I think you need to override using @AttributeOverride both the property and the method like this in the subclass:
@Entity
public class B {
@AttributeOverride(name = "fred", column = @Column(name = "FRED"))
private Integer fred;
@Override
public Integer getFred() {return fred;}
}
Upvotes: 3