I have a database view that yields a result set that has no true primary key. I want to use Hibernate/Persistence to map this result set onto Java objects. Of course, becaus
According to Hibernate user guide, using the pk is recommended so even if you are working with the existing project that doesn't contain the pk in the database side, you can add the pk column to the related database table and map it with the Java entities.
The hibernate recommendation was like that:
We recommend that you declare consistently-named identifier attributes on persistent classes and that you use a wrapper (i.e., non-primitive) type (e.g. Long or Integer).
For more detail about pk and Hibernate mechanism, please visit here
For each entity, you must designate at least one of the following:
so maybe you can create a composite primary key, containing multiple fields?
Modify your select used for view creation:
SELECT
ROWNUM ID, -- or use nextval of some sequence
-- other columns
FROM
TABLE
and map "ID" as primary key.