@Repository
class ShipRepository {
@PersistenceContext
private EntityManager entityManager;
@Override
public List<Ship> findLimitedTo(int limit) {
return entityManager.createQuery("SELECT s FROM Ship s ORDER BY s.id",
Ship.class).setMaxResults(limit).getResultList();
}
}