Reputation: 107
The code I use to list all entries of a table is the following:
entityManager.createQuery("SELECT * FROM Person WHERE Cn=?", Entry.class).getResultList();
(I hope it is correct I still don't run the application).
As from title, is it possible to list entries without specifying a query ?
Upvotes: 0
Views: 265
Reputation: 14806
Yes, if you use Criteria.
List<Person> persons = sessionFactory.getCurrentSession().createCriteria(Entry.class)
.add(Restrictions.eq("Cn", "some value")).list();
However, there is other magic. Called Spring Data. In Spring Data that would be
public interface PersonRepository extends JpaRepository<Person, Long> {
List<Person> findByCn(String cn);
}
Upvotes: 1