Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hibernate @AttributeOverride which results in setting the property as @Transient

Apart from this, if it is the right pattern to do it this way, the question is wheter is possible in a Hibernate for a given @MappedSuperclass set up the overriden property as a @Transient or ignore it in any 'other way'?

Given mapped superclass:

@MappedSuperclass
public abstract class MappedSuperclassEntity {
    private Integer field;
    public Integer getField() {return field;}
    public void setField(Integer field) {this.field = field;}
}
like image 885
Łukasz Rzeszotarski Avatar asked Oct 02 '22 20:10

Łukasz Rzeszotarski


1 Answers

That is not possible. Javadoc of @AttributeOverride :

(Required) The column that is being mapped to the persistent attribute. The mapping type will remain the same as is defined in the embeddable class or mapped superclass.

You can look at one of the three inheritance strategies for JPA here for another design.

like image 79
K.C. Avatar answered Oct 13 '22 11:10

K.C.