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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:36:28+00:00 2026-05-31T05:36:28+00:00

I have used this statements to populate jcombobox from MySql database table using Hibernate

  • 0

I have used this statements to populate jcombobox from MySql database table using Hibernate

    String SQL_QUERY ="from Item items";
        org.hibernate.Query query = session.createQuery(SQL_QUERY);
        for(Iterator it=query.iterate();it.hasNext();){
        Object[] row = (Object[]) it.next();
        jcbItemCode.addItem(row[0]);
        }

Here Item is my class name & items is my database table name. But NetBeans gives an error like follows & jcombo box does not populate.

INFO: schema update complete
Hibernate: select item0_.itemid as col_0_0_ from items item0_
eretailer.Item$$EnhancerByCGLIB$$99948c46 cannot be cast to [Ljava.lang.Object;

How can I correct this problem. I have searched but couldn’t find suitable answer.
I have used this method before…

String SQL_QUERY = "Select items.iid,items.idiscription,items.iprice from Item items";
          org.hibernate.Query query = session.createQuery(SQL_QUERY);
          for(Iterator it=query.iterate();it.hasNext();){
          Object[] row = (Object[]) it.next();
          jcbItemCode.addItem(row[0]);
          }

This is working perfectly.

Perhaps Net beans does not allow that way. I want to know what exactly this is. Hope your help.
Thanks!!!

  • 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-05-31T05:36:29+00:00Added an answer on May 31, 2026 at 5:36 am

    The query from Item items, as indicated by the error message, doesn’t return Object[] instances. It returns Item instances.

    If you want your combo box to contain Item instances, just use

    for(Iterator it = query.iterate(); it.hasNext();) {
        Item item = (Item) it.next();
        jcbItemCode.addItem(item);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have used this code for extracting urls from web page.But in the line
I have used code like this: http://msdn.microsoft.com/en-us/library/dw70f090.aspx to access database before when working in
I'm using SQL Server 2K8 and have a table used solely to generate ids
I have an application that reads a table from a database. I issue an
I'm currently using php to populate a form with selections from a database. The
I have a database table, 'Reports'. Each column in this table is of type
I have used this example to create a database that I copy over on
I have used this in my HTML: <q> Hai How r u </q> Which
I have used this effect before, everything is in order (As far as I
I am creating a rails app and have used this code in one of

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.