简体   繁体   English

休眠继承。 超类属性

[英]Hibernate Inheritance. super class attributes

I need to map a class to which I have no access. 我需要映射一个我无权访问的类。

@Entity
public class User extends org.springframework.security.core.userdetails.User {
    @Id
    @GeneratedValue
    private Integer id;
    private Integer age;
    ...
}

My tables are auto-generated and It only generate the columns at the subclass, how can I map the super class if I don't have access to annotate it with @Inheritance ? 我的表是自动生成的,并且仅在子类中生成列,如果我无权使用@Inheritance对其进行注释,该如何映射超类?

I tried with @AttributeOverrides(value = { @AttributeOverride( name = "username", column = @Column(name = "username")) }) but doesn't looks to work 我尝试了@AttributeOverrides(value = { @AttributeOverride( name = "username", column = @Column(name = "username")) })但没有用

I think the most convinient solution here is property access. 我认为这里最方便的解决方案是访问属性。 Just add a few overriding getters and annotate them: 只需添加一些覆盖的吸气剂并对其进行注释:

@Column("username")
public String getUsername(){
   return super.getUsername();
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM