title: Spring entity using a query instead of a table
body: <p>I have a POJO class (Named "Instance") with attributes to hold information about some features of some instances in our servers. However the source this table's data comes from is not under my control, and requires me to use a custom SQL query (Precisely: <code>select **distinct** assetid, fqdn, department, vdc, from my_table_name</code> as the table contains compliance results of some rules applied to those instances, which I don't need so I just get the instances ) instead of having the data available in its own table.</p>
  
  <p>So, instead of using <code>@Table</code> annotation, I'm forced to use some custom query to achieve the same result. However I have been researching and I can't find a way to assign this query to my <code>@Entity</code> just like I do with <code>@Table("mytable")</code>. I'd like to be able to use spring-data-jpa-datatables as well, due to the potentially high volume of elements and processing to be done, but I'm not sure if this can be achieved.</p>