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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T03:34:23+00:00 2026-06-17T03:34:23+00:00

I have my Native SQL statement like this: SQLQuery: select Name ,Id,COUNT(ID) from Employee;

  • 0

I have my Native SQL statement like this:

SQLQuery:

select Name ,Id,COUNT(ID) from Employee;

Employee HBM file:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC 
    "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
    <class name="edu.model.Master" table="test_prefixmaster">
        <id name="empcode" column="EMPCODE" length="10" ></id>

        <property name="empname">
            <column name="NAME" length="30" />
        </property>
    </class>
    <sql-query name="SQLQuery" callable="true">
    <return alias="emp" class="edu.model.Employee">
        <return-property name="empid" column="EMPID" />
        <return-property name="empname" column="EMPNAME" />
        </return>
        </sql-query>
</hibernate-mapping>

In MyTest Class:

   Query query = session.getNamedQuery("SQLQuery");
    List emp=new ArrayList();
    for (int i = 0; i < emp.size(); i++) {                  
    Employee emp = (Employee) emp.get(i);
    System.out.println("Employee Id:::" + emp.getEmpId());
   System.out.println("Employee Name:::" + emp.getEmpname());
//I want to get here System.out.println("Employee Count");
}

How can I map and print the Employee count also in the loop?

  • 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-17T03:34:24+00:00Added an answer on June 17, 2026 at 3:34 am
       Query query = session.getNamedQuery("SQLQuery");
        List empList=new ArrayList();
        for (int i = 0; i < empList.size(); i++) {                  
        Employee emp = (Employee) empList.get(i);
        System.out.println("Employee Code:::" + emp.getEmpcode());
       System.out.println("Employee Name:::" + emp.getEmpname());
    
    //I want to get here System.out.println("Employee Count");
       System.out.println("Employee Count:::" + empList.size());
    }
    

    for Distinct Employee

    change your query

    select Name ,distinct (Id) from Employee ;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a DataTable obtained from a SQL DataBase, like this: using (SqlCommand cmd
I am using hibernate. I have written native SQL query and I would like
Say I have the following native SQL: SELECT a, b, c + d AS
I have a query like queryStr := 'SELECT col1, col2, col3, col4 FROM Table1
This prepared statement seems like valid SQL to me. PreparedStatement dropTable = cnx.prepareStatement( DROP
This is probably a multi-part question. Background: we have a native (c++) library that
Sometimes you have to write some of your queries in native SQL rather than
I have a native SQL query that returns several computed results (such as sums
I have several NHibernate mappings using a sql-insert element to override the native insert
I have native facebook app in development for few months and login worked on

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.