1

Hi I would like to select column from one table while ordering from column of another table. Effect should be same as this SQL:

SELECT DISTINCT m.marker_name FROM Marker m INNER JOIN Lease l ON m.marker_name = l.marker_name ORDER BY l.location

Table marker

╔═════════════╗
║ marker_name ║
╠═════════════╣
║ ABC         ║
╟─────────────╢
║ DEF         ║
╚═════════════╝

Table lease:

╔══════════╤═════════════╗
║ location │ marker_name ║
╠══════════╪═════════════╣
║ 01-01    │ ABC         ║
╟──────────┼─────────────╢
║ 01-02    │ DEF         ║
╟──────────┼─────────────╢
║ 01-01    │ GHI         ║
╟──────────┼─────────────╢
║ 01-02    │ JKL         ║
╚══════════╧═════════════╝

I tried with following JPA/Hibernate SQL but failed:

@Query("SELECT DISTINCT m.markerName FROM Marker m INNER JOIN Lease l ON m.marker_name = l.marker_name ORDER BY l.location")
List<String> findDistinctMarkernameOrderByLocation();

Error:

Path expected for join! [SELECT DISTINCT l.markerName FROM Lease l INNER JOIN Marker m ON m.marker_name = l.marker_name ORDER BY l.location]

I am trying to avoid use of native query so just wonder if any JPQL will work.

LOUDKING
  • 301
  • 1
  • 13
  • Try the same approach described on below thread https://stackoverflow.com/questions/28234754/jpa-exception-path-expected-for-join – Abin Manathoor Devasia Oct 10 '17 at 03:06
  • Possible duplicate of [JPA exception :: path expected for join](https://stackoverflow.com/questions/28234754/jpa-exception-path-expected-for-join) – Abin Manathoor Devasia Oct 10 '17 at 03:06
  • JPQL uses classes/fields, and you don't post what are the classes/fields. Can you see the problem with that ? –  Oct 10 '17 at 07:52

0 Answers0