1

I'm using @MappedSuperclass annotation in the following way:

@MappedSuperclass
public abstract class Recipient {
    @Id
    @Column(name = "id")
    private int id;

    @Column(name = "email")
    private String email;

    //GET, SET
}

I also have two entity classe, inherited from one:

public class Player extends Recipient{
    //FIELD, GET, SET
}

and

public class Partner extends Recipient{
    //FIELD, GET, SET
}

The thing is private int id filed in the class Player has an additional attribute:

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private int id;

Is it possible to specify that? We can override attribute with annotation @AttributeOverride, but what about to add one?

St.Antario
  • 26,175
  • 41
  • 130
  • 318
  • 1
    You can't. I tried to solve a similar problem here: [How to create a generic entity model class that supports generic id including auto generated ids?](http://stackoverflow.com/q/26109041/1065197). At the end, I have different classes for id support and my classes have to extend one or another since Java doesn't allow multiple class inheritance. – Luiggi Mendoza Nov 06 '14 at 16:55

0 Answers0