You are missing a field annotated with @Id
. Each @Entity
needs an @Id
– this is the primary key in the database.
If you don’t want your entity to be persisted in a separate table, but rather be a part of other entities, you can use @Embeddable
instead of @Entity
.
If you want simply a data transfer object to hold some data from the hibernate entity, use no annotations on it whatsoever – leave it a simple pojo.
Update: In regards to SQL views, Hibernate docs write:
There is no difference between a view and a base table for a Hibernate mapping. This is transparent at the database level