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

  • Home
  • SEARCH
  • 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 7975913
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T08:46:33+00:00 2026-06-04T08:46:33+00:00

I have written a code like this to fetch data from database using HQL:

  • 0

I have written a code like this to fetch data from database using HQL:

Query qr=sess.createQuery("select i.contract_Vcode,i.installment_date from Installment i where i.vcode=:instalVcode").setParameter("instalVcode", installVcode);
        qr.getNamedParameters();
List<Installment> li=null;
        li=qr.list();
int coVcode=li.get(0).getContract_Vcode();

As I know the contract_Vcode is an integer. But when I want to run it, the followed error happens:

Error invoking Action using Hibernate Core Session / Transaction injection
java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to information.Installment

More over when I want to see the exact element like this,

System.out.println("contract installDate is: "+li.get(0).getContract_Vcode());

Same error happens. How can I fix this?

  • 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-04T08:46:34+00:00Added an answer on June 4, 2026 at 8:46 am

    You’re currently only querying two parts of an installment. If you want to fetch the whole thing, I’d expect something like:

    Query qr = sess.createQuery(
                        "select from Installment as i where i.vcode=:instalVcode")
                   .setParameter("instalVcode", installVcode);
    

    If you fetch multiple properties (instead of whole entities), you just get back an Object[] for each row in the results.

    So you could use your original query, but:

    List<Object[]> li = qr.list();
    int coVcode = (Integer) li.get(0)[0]; // 1st column of 1st row
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written some thing like this to fetch data from the database. public
I have written in my code like this... $this->User->saveAll($this->data, array('validate'=>'first')); $this->User->saveAll($this->data, array('validate'=>false)); 'validate'=>false will
I have my code written to select images from my database and display them,
Hi I have written code like this @Id @Column(nullable=false) @GeneratedValue(strategy=GenerationType.AUTO) public int getUserID() {
In our application, I have seen code written like this: User.java (User entity) public
I have always written my boolean expressions like this: if (!isValid) { // code
I have written code like this to throw a pop up when my website
I have written in my code something like this and the strange thing is
I have written some data fetch service which fetches some entities from main web
i have code written something like this. if(!isset($cid)) { echo <script type=\text/javascript\>alert('OOps, Something went

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.