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 7739885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T08:38:09+00:00 2026-06-01T08:38:09+00:00

Why does this query work normal: Query query = session.createQuery(from Table tab); And this

  • 0

Why does this query work normal:

Query query = session.createQuery("from Table tab");

And this query:

Query query = session
  .createQuery("select tab.col1, tab.col2, tab.col3 from Table tab");

And that’s what I’m doing with both queries:

dataList = query.list();
for (Table item : dataList)
{
  System.out.println(item.getCol1();
}

reports:

java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to table.Table
at test.TestCriteria.main(TestCriteria.java:35)

Could you help?

Table is normally mapped in entity bean and all the columns are correct.

  • 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-01T08:38:10+00:00Added an answer on June 1, 2026 at 8:38 am

    I believe in the second query, the result is a List<Object[]>:

    Object[] row = (Object[]) dataList.get(i);
    Object col1Value = row[0];
    Object col2Value = row[1];
    Object col3Value = row[2];
    

    I have this guess observing Ljava.lang.Object; in the exception trace.

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

Sidebar

Related Questions

Why does this MySQL query take forever (and never finishes) on a table that
I cannot understand this query? select @:vfOutBalance+@:vfHSSubTotal+@3+orpartpayment,@:vfOutBalance+@:vfHSSubTotal from or_equip_upgrd_id what does @3 mean?
I am trying to optimize a query that does something like this: SELECT ...
Why does this query NOT work FROM WorkflowConfiguration WHERE ((saReplacement IS NOT NULL) AND
Normal query manner: Session sess=factory.getCurrentSession(); sess.beginTran....(); String hql=from Entity en where en......; Query q=sess.createQuery(hql).setCacheble(true);
This code does not throw an error but the query fails, that is, the
How do I make this query work like it does in sql? In sql
I have this query that works fine. It selects rows into the SY.UserOptions table
The naive attempt query would look like this: Query query = em.createQuery(from org.domain.Resource r
We have a registration system Database and basically what this query does is check

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.