Skip to content
Advertisement

JPA Entity for View containig joins and aliases

I have the following query using which I want to create an entity class for the columns which I am retrieving from the query.

JavaScript

How to create an entity class from these columns and what variables are needed to take it in entity class to refer to these columns?

Advertisement

Answer

View is a virtual table based on the result-set of an SQL statement or a function and JPA treats it as a regular table. Create a entity and use JPA annotations as below

JavaScript

For more details, refer to this article that I found https://medium.com/@jonathan.turnock/exposing-subset-view-of-the-database-with-a-jpa-repository-over-rest-5b9d6e07344b

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement