Spring JPA - Add property from query to entity

Viewed 50

I have the following DB table and view:

business table:

id | name | ...

business_status_summary_view:

business_id | ... | status

In my Java business entity, I'd like to have a 'status' field pulled as a String from the view, like so:

@Entity
@NoArgsConstructor
@Table(name = "business", schema = "public")
public class Business {
    @id
    public Long id;
    public String name;
    public String status; // <-- this needs to come from the view
}

How can I map this? I've been looking at posts but haven't really found a solution that fits.

Please note there is no entity for the view, it's strictly in the db.

0 Answers
Related