Search code examples
javajpaannotationseclipselinktoplink

JPA1 - ID is part of superclass results into error because of missing @Id in @Entity annotated class


we are currently evaluating JPA for our persistence unit and we got a problem when the id is part of the superclass. We always get the error message that the @Id must be in the same class as the @Entitiy annotation.

public abstract class DomainBean {

@Id
private long id;

}

@Entity
public class property extends DomainBean {}

We could archive this problem when we use a XML mapping file. Is there any known resolution by using annotations?

Due to the problem that we must use WebLogic 10.3.1 we are limited to JPA1 and EclipseLink/TopLink but we can't find any solution.


Solution

  • DomainBean must be annotated with @MappedSuperclass for its JPA annotations to take effect.