0

I've created a view in Postgresql

CREATE OR REPLACE VIEW tenant3.user_accounts AS 
 SELECT foo.c1
   FROM tenant3.dblink('dbname=genesis_admin'::text, 'SELECT username FROM user_account'::text) foo(c1 text);

I want to create a JPA entity that maps to this View so that I can query the said view using Spring Data JPA. is it possible? if so, how?

How would I map the said view to a Spring Data JPA Entity?

1 Answer 1

0

Yes, it is possible to map views to JPA entities. After all, JPA does not distinguish between tables and views. Just make sure that the view has a "primary key" (a column or a group of columns that are not null and identify the row).

If you don't want the entity to be read only, add the appropriate rules and/or triggers.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.