So, here is my entity:
@Entity
@Table(name = "stats_search")
public class Search implements Serializable {
/**
* id du departement
*/
@Id
@GeneratedValue
@Column(name = "stats_search_uuid")
@Type(type="pg-uuid")
private UUID id;
@Column
private Double lat;
@Column
private Double lng;
@Column
private Integer radius;
}
And its repository:
public interface StatSearchRepository extends JpaRepository<Search, UUID> {
@Query(value = "SELECT Cast(stats_search_uuid as varchar) FROM stats_search " +
"WHERE ip_address = :ipAddress " +
"AND search_time > (NOW() - ((INTERVAL '1 seconds') * :delay)) " +
"ORDER BY search_time DESC LIMIT 1",
nativeQuery = true)
String countByIp(String ipAddress, Integer delay);
}
My custom method returns an existing id, but when I call findById() with this id, it returns a null result.