I have to map the interface as entity to use different implementations in collections.
@Entity
@Table(name = "OPTION")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "TYPE", discriminatorType = DiscriminatorType.STRING)
public interface FilterOption {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
public Long getId();
public void setId(Long id);
public Object getValue();
...
}
I’m recieving an error :
Internal Exception: Exception [EclipseLink-7161] (Eclipse Persistence
Services – 2.2.0.v20110202-r8913):
org.eclipse.persistence.exceptions.ValidationException Exception
Description: Entity class [class
FilterOption] has no primary
key specified. It should define either an @Id, @EmbeddedId or an
@IdClass.
As you can see the @Id is declared. How can I fix this problem?
you can’t map entities to interfaces using annotations with eclipselink, apparently.
In fact, you can’t map an entity to an interface at all using jpa or hibernate.