I have a class A and class B
public class A{
int f1;
int f2;
int f2;
}
public class B extends A{
}
my question is how to ignore a field for example 'f2', in the table mapped to B?
I will try to answer assuming the edit I have made to your post is approved. In the code below I am ignoring the field f2 from class A i.e. superclass of B using AttributeOverride.
@Entity
@AttributeOverride(name = "f2", column = @Column(name = "f2_col", insertable = false, updatable = false)
public class B extends A{
}
If you want to read about it further, refer to AttributeOverride.
AttributeOverride with insertable = false
, updatable = false
should help, but it also depends on your inheritance strategy. It just helps making mapped fields inherited from a superclass transient, so that some other subclass can use it but it will be ignored for this particular sub class.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With