I'm trying to get the latest entry for each group and I got a query from this post
and here is the query
SELECT t1
FROM TrainTable t1 LEFT JOIN TrainTable t2
ON (t1.Train = t2.Train AND t1.Time < t2.Time)
WHERE t2.Time IS NULL;
When I try to implement the same query in Spring data JPA @Query, I'm getting
Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: Path expected for join! [SELECT t1
FROM TrainTable t1 LEFT JOIN TrainTable t2
ON (t1.Train = t2.Train AND t1.Time < t2.Time)
WHERE t2.Time IS NULL]
Is there any possible way to use the same table entity in left join?