简体   繁体   English

如何从@MappedSuperclass中排除休眠模式自动生成中的字段?

[英]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.

相关问题 如何从hibernate auto ddl中排除模式 - How to exclude schema from hibernate auto ddl 从数据库中选择MappedSuperclass(休眠) - Selecting MappedSuperclass from the database (Hibernate) Hibernate无法确定MappedSuperClass字段的类型 - Hibernate could not determine type of MappedSuperClass field 在Spring JUnit测试中,如何在休眠自动生成之前初始化数据库? - How to initialize database before hibernate autogeneration in a Spring JUnit Test? 休眠注释-@MappedSuperclass如何覆盖列标识符 - Hibernate Annotations - @MappedSuperclass How to override column identifier 与MappedSuperclass中的字段在同一个实体上的ManyToMany - ManyToMany on same Entity with field from MappedSuperclass 如何使用 JPA/hibernate 创建索引并将 MappedSuperClass 中的字段与具体实体中的字段一起使用 - How to create an index with JPA/hibernate and use fields from MappedSuperClass together with fields from concrete entity 如何从Hibernate @MappedSuperclass覆盖一种方法但保留原始映射? - How can one override a method from a Hibernate @MappedSuperclass but keep the originial mapping? 如何从Hibernate Search结果中排除将isDeleted数据库字段设置为0的实体? - How to exclude entities that have isDeleted database field set to 0 from Hibernate Search results? 休眠-超类-映射超类 - Hibernate - SuperClass -MappedSuperClass
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM