Java Spring @MappedSuperclass field as @Id field in child class

229 Views Asked by At

I have the following superclass that will be extended by many classes. Its one property, foreignKey, will be the @Id for one of the inheriting classes.

The superclass:

@MappedSuperclass
public abstract Superclass {
    
    @Column(name="FOREIGN_KEY")
    private String foreignKey;

    // Getters and setters
}

The inheriting class:

@Entity
public class ClassA extends Superclass {
    
    @Id
    @Column(name="FOREIGN_KEY")
    private String foreignKey;

    // Getters and setters
}

When I try building I am given the error:

No identifier specified for ClassA

Is there anyway to accomplish this?

0

There are 0 best solutions below