[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.rt.eclipselink] Inheritance problem with Id in subclass

Hello

I have quite a problem with my inheritance. According to the documentation I dont need a id column in the subclass, but when I start my EntityManager, it always wants an Id for it.
Here is what I did


Person:

@Entity @Table(name="Persons")
@Inheritance(strategy = InheritanceType.JOINED)
@DiscriminatorColumn(name = "TYPE")
public class Person {

    @Id
    @GeneratedValue
    protected int id;
    @Column(nullable = false)
    protected String firstName;
    @Column(nullable = false)
    protected String lastName;

Customer:

@Entity @Table(name = "Customers")
@DiscriminatorValue("C")
public class Customer extends Person {

    //no id needed here


I tried all things that came in my mind: macking the id-attribute protected so the subclass can see it (but in tutorials nobody does that), and I tried to make the parent abstract. But none of these helped. EclipseLink still complains that my Customer-class has no primary key with @Id.
I also thought that my persistence.xml is wrong so I played around here, but as far as I know I should name all classes there as well.


I have no idea why this is not working. Can somebody help me out here.
Thanks