Как с помощью своей @Query в JpaRepository одного объекта, вытащить другой объект
Как в JpaRepository<Geolocation, Long> вытащить своим запросом список другого объекта Test, или может есть возможность вытащить List и как то его перевести в List?
public interface GeolocationRepository extends JpaRepository<Geolocation, Long> {
@Query(value = "select Distinct date as date, count(date) as count from geolocations where user_id = ? group by date;", nativeQuery = true)
List<Test> get(User user);
}
@Entity
@Table(name = "geolocations")
public class Geolocation {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "latitudes")
private float latitudes;
@Column(name = "longitudes")
private float longitudes;
@Column(name = "date")
private Date date;
@Column(name = "time")
private Time time;
@OneToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "user_id")
private User user;
}
public class Test {
Date date;
int count;
public int getCount() {
return count;
}
public void setCount(int count) {
this.count = count;
}
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
}
}