简体   繁体   中英

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 ?

I tried with @AttributeOverrides(value = { @AttributeOverride( name = "username", column = @Column(name = "username")) }) but doesn't looks to work

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();
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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