xedo
xedo

Reputation: 1147

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

Upvotes: 2

Views: 686

Answers (1)

Gergely Bacso
Gergely Bacso

Reputation: 14651

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

Upvotes: 3

Related Questions