[英]How to exclude a field in hibernate schema autogeneration from @MappedSuperclass?
How can I tell hibernate
to ignore a field during schema auto generation? 如何在架构自动生成过程中告诉
hibernate
忽略字段? In this special case: the field is inherited from a parent abstract class, so I cannot just comment it out! 在这种特殊情况下:字段是从父抽象类继承的,所以我不能仅仅将其注释掉!
I tried using @Transient
, but the field is still autogenerated in the schema. 我尝试使用
@Transient
,但该字段仍在架构中自动生成。
@MappedSuperclass
public abstract class BaseEntity {
private String someField;
//getter+setter
}
@Entity
public class MyEntity extends BaseEntity {
@Transient //I want to ignore this field during hibernate.ddl.auto
@Override
public String getSomeField() {}
}
Add the Transient annotation in the super class: 在超类中添加Transient批注:
@MappedSuperclass
public abstract class BaseEntity {
@Transient
private String someField;
}
@Entity
public class MyEntity extends BaseEntity {
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.