Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- em.getTransaction().begin();
- List<Address> addresses = em.createQuery("SELECT a FROM Address a ORDER BY a.employees.size DESC, a.town.id ASC",Address.class)
- .setMaxResults(10).getResultList();
- for (Address address : addresses) {
- System.out.printf("%s, %s - %d employees%n",
- address.getText(),
- address.getTown().getName(),
- address.getEmployees().size());
- }
- em.getTransaction().commit();
- em.close();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement