In caso di @Inheritance(strategy = InheritanceType.JOINED)
, quando recuperi dati senza nativeQuery=True
in repository JPA , Iberna eseguirà SQL come il seguente:
SELECT
table0_.id as id1_1_,
table0_.column2 as column2_2_1_,
... (main_table cols)
table0_1_.column1 as column1_1_0_,
... (table1 to N-1 cols)
table0_N_.column1 as column1_1_9_,
... (tableN-th cols)
CASE WHEN table0_1_.id is not null then 1
... (table1 to N-1 cols)
WHEN table0_N_.id is not null then N
WHEN table0_.id is not null then 0
END as clazz_
FROM table table0_
left outer join table1 table0_1_ on table0_.id=table0_1_.id
... (other tables join)
left outer join table2 table0_N_ on table0_.id=table0_N_.id
Dall'SQL sopra puoi vedere clazz specifica. Se vuoi mappare ResultSet nella tua super istanza (PlaceEntity), dovresti specificare clazz_ colonna in SELECT da solo.
Nel tuo caso sarà:
@Query(value = "" +
"SELECT *, 0 AS clazz_ " +
"FROM place " +
"WHERE earth_distance( " +
" ll_to_earth(place.latitude, place.longitude), " +
" ll_to_earth(:latitude, :longitude) " +
") < :radius",
nativeQuery = true)