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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T19:07:52+00:00 2026-06-04T19:07:52+00:00

I have table with following table schema : I have created a method that

  • 0

I have table with following table schema :

enter image description here

I have created a method that returns the list of value on query execution.

    protected List findAllWithGroupClause(Class clazz) {

    List objects = null;
    try {
        startOperation();
        String SQL_QUERY = "SELECT COUNT(serviceName) AS RunningInstances ,serviceName,SUM(numberofthread) as workerThread "
                + "FROM servicemanagerdetails WHERE servicemanagerstatus=:status GROUP BY serviceName";
        Query query = session.createQuery(SQL_QUERY);
        query.setString("status", "Running");
        objects = query.list();
        tx.commit();
    } catch (HibernateException e) {
        handleException(e);
    } finally {
        HibernateFactory.close(session);
    }
    return objects;
}

and for that declared ServiceManagerDetails.hbm.xml file:

  <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
  <class name="com.arosys.hibernatedatamanager.ServiceManagerDetails" table="servicemanagerdetails">
    <id column="servicedetailsid" name="servicedetailsID" type="integer">
      <generator class="increment"/>
    </id>
    <property column="serviceID" name="servicemanagerID" type="string"/>
    <property column="servicemode" name="servicemode" type="string"/>
    <property column="servicetype" name="servicetype" type="string"/>
    <property column="servicemanagerstatus" name="servicemanagerstatus" type="string"/>
    <property column="controlqueue" name="controlQueue" type="string"/>
    <property column="controlexchange" name="contolExchange" type="string"/>
    <property column="controlroutingkey" name="controlRoutingkey" type="string"/>
  </class>
</hibernate-mapping>

i have created column alias for that it is necessary to write setter and getter method as well as define mapping?please explain how can retrieve value from list.

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-06-04T19:07:55+00:00Added an answer on June 4, 2026 at 7:07 pm

    You have a select statement for selecting aggregate functions COUNT, SUM etc. In this case the hibernate Query.list() returns a list of arrays of objects.

    If you want to get the SUM of the fourth row, you do

    Object obj4[] = objects.get(3);
    long sum4 = ((Number)obj4[2]).longValue();
    

    and for the serviceName of the third row you do

    Object obj3[] = objects.get(2);
    String name2 = (String)obj4[2];
    

    (both examples for explaining; your code will look more variable).

    You do not need to write getters and setters, you even can’t do that. You can’t use the column aliases outside the select string.

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

Sidebar

Related Questions

I have a DB table that uses the following schema: CREATE TABLE users (id
I have a table created with the following schema: CREATE TABLE [dbo].[Visualizations] ( VisualizationID
I have a bunch of coordinates in my table grid with the following schema
I have the following pseudo-SQL schema: table flight id int primary key date timestamp
I have no control over database schema and have the following (simplified) table structure:
I have created Rails database using the following schema: ActiveRecord::Schema.define(:version => 20090807141407) do create_table
I have the following Entity: @Entity @Table @NamedQuery(name = Constants.FINDALLFINDERNAME, query = Constants.FINDALLQUERY) public
I have a MySQL table with the following schema: +---------+---------+----------------------+------------+ | User ID |
I currently have the following (simplified) class / db schema: Entity Prospect Customer +-
I have table with following structure and test records: +--------+--------+---------+ | vid | number

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.