JPA Repository is quite limited compared to the direct query to the database (at least from what I've seen while using it)
You can send a query directly from the Controller / where is your method using JdbcTemplate
// Autowiring JdbcTemplate so we can send queries to the database
@Autowired
JdbcTemplate jdbcTemplate;
public List<Map<String, Object>> mock_method() {
// Your query
String query = " select nc.* from Table1 n, Table2 nc
where n.destination = nc.client_id and n.status = 'Created';";
return jdbcTemplate.queryForList(query);
}
This method will return a list of Map<String, Object>, where String is the name of the column, and Object is the value from that column (this way it can retrieve any type of data, then you can parse it to the needed type)
If there are no rows that match the query it will return nothing, so there is no need for error handling.