Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8642145
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T11:42:12+00:00 2026-06-12T11:42:12+00:00

final List<Tuple> data = em.createQuery(SELECT p.id AS i, p.membership AS m FROM Player p

  • 0
final List<Tuple> data =
                    em.createQuery("SELECT p.id AS i, p.membership AS m FROM Player p WHERE p.id IN :ids", Tuple.class)
                    .setParameter("ids", ids)
                    .getResultList();

This gives the error “Cannot create TypedQuery for query with more than one return“. I could work around that by leaving out the type parameter (and using Object[] instead of Tuple, as I later found out):

@SuppressWarnings("unchecked")
final List<Object[]> data =
                    em.createQuery("SELECT p.id AS i, p.membership AS m FROM Player p WHERE p.id IN :ids")
                    .setParameter("ids", ids)
                    .getResultList();

But is there a solution that doesn’t require unchecked code?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T11:42:14+00:00Added an answer on June 12, 2026 at 11:42 am

    A tuple isn’t really any more typesafe than an array, is it?

    What you could do here is use a constructor expression. Off the top of my head, this is 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 hold the result, but this will typically be pretty trivial.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

final Criteria crit = session.createCriteria(MyClass.class); final List<MyClass> myClassList = crit.list(); results in this :
I have this code: public static final <TypeVO extends BaseVo> List<SelectItem> populateSelectBoxForType( final Class<TypeVO>
I've got a class somewhat like this: public class Test { private final List<ISomeType>
considering this example: public static void main(final String[] args) { final List<String> myList =
This code is from the Wicket in Action book. final WebMarkupContainer parent = new
I have something like public void setCustomHandler(final List<ClassA> customHandler) { this.customHandler = customHandler; }
I was reading through some JMockit examples and found this code: final List<OrderItem> actualItems
Supposing I have a list/tuple like this: MyLocation = 'DE' ( ('Pencils', 'Artists Pencils',
final public class ImmutableWithObject { final Object obj; final List myList; ImmutableWithObject(Object obj1, List
I am trying to create a dictionary from a list and tuple of tuples

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.