Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible in JPA to redefine inherited attributes as transient?

@MappedSuperclass
public abstract class BaseBean{
    @Id
    @GeneratedValue
    Long id;
    String name;
}

@Entity
public class A extends BaseBean{

}

@Entity
public class B extends BaseBean{

}

Is it possible to set the name attribute as transient just for the class B

like image 286
SEY_91 Avatar asked Oct 19 '25 14:10

SEY_91


1 Answers

No, it doesn't work. The @MappedSuperclass fields/properties are always considered and even when you use property-access and try to override the properties with different annotation, Hibernate will still use the one from the base class.

like image 168
Vlad Mihalcea Avatar answered Oct 21 '25 03:10

Vlad Mihalcea



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!