@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
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.