A tuple is actually not more typical than an array, is it?
What you can do here is use a constructor expression. At the top of my head, it's something like:
class PlayerMembership {
public final int id;
public final MembershipType membership;
public PlayerMembership(int id, MembershipType membership) {
this.id = id;
this.membership = membership;
}
}
List<PlayerMembership> data =
em.createQuery("SELECT NEW nl.bart.PlayerMembership(p.id, p.membership) FROM Player p WHERE p.id IN :ids", PlayerMembership.class)
.setParameter("ids", ids)
.getResultList();
This requires you to write a new class to store the result, but this is usually pretty trivial.
source
share