I have this JPA Repository for a user model. And I want to take the very recent data which is the first data that came out. But since I'm using spring-data-jpa.1.0.2-REALEASE, I can't use "findFirstBy" to get what I want.
so I try using nativequery, which has a lot of ways to use and is different in every version. (I guess) anyway, my code would be something like this :
public interface UserRepository extends JpaRepository<UserModel, Long>, QueryDslPredicateExecutor<UserModel> {
@Query("SELECT u FROM user u where u.userDevice_id = :uid ORDER BY u.Time DESC LIMIT 1")
UserModel findFirstByUserDeviceOrderByTimeDesc(@Param("uid") Long uid);
.......
}
but it returning this error
org.hibernate.hql.ast.QuerySyntaxException: user is not mapped
I can't carelessly change my spring version because I'm using an old environment.