JPQL (HQL)

@Override
public void run(ApplicationArguments args) throws Exception {
	Query query = entityManager.createQuery("SELECT p FROM Post AS p", Post.class);
	List<Post> posts = query.getResultList();
	posts.forEach(System.out::println);
}

Criteria

@Override
public void run(ApplicationArguments args) throws Exception {
	CriteriaBuilder builder = entityManager.getCriteriaBuilder();
	CriteriaQuery<Post> query = builder.createQuery(Post.class);
	Root<Post> root = query.from(Post.class);
	query.select(root);

	List<Post> posts = entityManager.createQuery(query).getResultList();
	posts.forEach(System.out::println);
}

Native Query

@Override
public void run(ApplicationArguments args) throws Exception {
	List<Post> posts = entityManager.createNativeQuery("SELECT * FROM Post", Post.class).getResultList();
	posts.forEach(System.out::println);
}