Hibernate and no PK

database, hibernate, java, jpa

Solution

I found that its not possible to do so. So bad luck for those working with legacy systems.

If you reverse engineer (create JPA annotated entities from existing JDBC connection) the table will create two Java classes, one Entity and with one field; id, and one embeddable id containing all the columns from your relation.

Problem

Is it possible to create a table (from a JPA annotated Hibernate `@Entity`) that does not contain a primary key / Id? I know this is not a good idea; a table should have a primary key.

Original source

Related problems