Changed hardcoded SQL into JPA equivalent