I have this super-class
open class Base(
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY) var id: Long = 0,
@Column var userId: Long? = 0,
@Column var created: Date = Date(),
@Column var updated: Date = Date(),
@Column var currency: String = ""
)
which I then inherit in the following class
@Entity
@Table(name = "foo")
class Foo(
@Column var name: String = "",
) : Base()
Now the compiler complains
Persistent entity ‘Foo’ should have primary key
But the id is defined in Base. Why is it complaining?
>Solution :
But the
idis defined inBase. Why is it complaining?
Possibly because annotations on the superclass and its members are of interest to JPA only if the superclass is a Foo does not appear to inherit from Base. But even if it did inherit from Base,@MappedSuperclass or an @Entity itself.