1

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: select **distinct** assetid, fqdn, department, vdc, from my_table_name 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.

So, instead of using @Table 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 @Entity just like I do with @Table("mytable"). 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.

Dragan Bozanovic
  • 23,102
  • 5
  • 43
  • 110
fernandopcg
  • 514
  • 6
  • 20
  • 1
    [This answer](http://stackoverflow.com/a/34546581/4754790) might be helpful. – Dragan Bozanovic May 31 '16 at 16:29
  • @DraganBozanovic yeah, when I was driving back home I thought of creating a view and using that in lieu of a standard table. Will check it out and update! – fernandopcg May 31 '16 at 20:29
  • @DraganBozanovic yes, that did the trick. If you wish you can provide a proper answer with the same content so I can mark it as the solution and give your deserved rep ^^ – fernandopcg Jun 01 '16 at 10:14

0 Answers0