@Test public void testNew() { TypedQuery<Message> query = em.createQuery( "select NEW " + Message.class.getName() + "(u.name) from User u", Message.class); List<Message> messages = query.getResultList(); assertEquals(4, messages.size()); assertTrue(messages.stream().map(Message::getText).anyMatch(t -> t.equals("A"))); assertTrue(messages.stream().map(Message::getText).anyMatch(t -> t.equals("B"))); assertTrue(messages.stream().map(Message::getText).anyMatch(t -> t.equals("C"))); }
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; }