@Test public void testOderBy() { TypedQuery<User> query = em.createQuery("select u from User u order by u.friends.size ASC", User.class); query.setMaxResults(2); List<User> users = query.getResultList(); assertEquals(2, users.size()); assertEquals("C", users.get(0).getName()); assertEquals("B", users.get(1).getName()); }
public String getName() { return name; }
User { public String getName() { return name; } }
User { public String getName() { return name; } User(); }
User { public String getName() { return name; } User(); List<User> getFriends(); Address getAddress(); Long getId(); void setId(Long id); String getName(); void setName(String name); void setAddress(Address address); void setFriends(List<User> friends); }
User { public String getName() { return name; } User(); List<User> getFriends(); Address getAddress(); Long getId(); void setId(Long id); String getName(); void setName(String name); void setAddress(Address address); void setFriends(List<User> friends); static final String GET_ALL; static final String GET_ALL_IN_NORWAY; }