休眠 :如何覆盖映射的超类中的属性
2022-09-01 23:01:17
泛型实体,超类:
@MappedSuperclass
public abstract class GenericEntity {
private Integer id;
public Integer getId() {return id;}
public void setId(Integer id) {this.id = id;}
}
Pojo:
@Entity
@Table(name = "POJO_ONE")
@SequenceGenerator(name = "HB_SEQ_POJO_ONE", sequenceName = "SEQ_POJO_ONE", allocationSize = 1)
public class PojoOne extends GenericEntity {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "HB_SEQ_POJO_ONE")
@Column(name = "ID")
@AttributeOverride(name = "id", column = @Column(name = "ID"))
private Integer id;
@Override
public Integer getId() {return id;}
}
我尝试使用这些注释:@AttributeOverride,@Id,...但它不起作用。你可以帮我吗?我想覆盖属性“id”以指定另一个列名和pojo/table的序列。最好的方法是什么?