2

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?

user2360507
  • 93
  • 1
  • 7
  • can't understand why you are declaring the property twice in the Parent class and its child ! however did you checked the import statement are they correct ? – Abdelghani Roussi Nov 01 '20 at 21:16
  • @AbdelghaniRoussi I redeclare it to add the Id annotation to it. I do this in the subclass because I only want this subclass to have the field as an Id. All other subclasses will not have the field redeclared. I'm open to additional ways to mark the field as an Id instead of redeclaring it. – user2360507 Nov 01 '20 at 21:22

0 Answers0