I'm attempting to create a JPA entity for a view. From the database layer, a table and a view should be the same.
However, problems begin to arise and they are two fold:
When attempting to setup the correct annotations. A view does not have a primary key associated with it, yet without the proper
@javax.persistence.Id
annotated upon a field, you will get anorg.hibernate.AnnotationException: No identifier specified for entity
thrown at Runtime.The Spring Boot
JpaRepository
interface definition requires that theID
type extendsSerializable
, which precludes utilizingjava.lang.Void
as a work-around for the lack of an id on an view entity.
What is the proper JPA/SpringBoot/Hibernate way to interact with a view that lacks a primary key?