Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Hibernate how to iterate hibernate object
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Ravi
how to iterate hibernate object
2 Answer(s)      3 years and 10 months ago
Posted in : Hibernate


am just learning hibernate .by the hibernate am getting one list to display a grid(grid has 5 column). now i want to iterate one only column value to calculate total of that particular column. how to do this....


Advertisement
View Answers

December 2, 2010 at 7:53 PM


Hi,

You can use the iterator class to iterate the data.

Here is example code:

Iterator it = list.iterator(); while(it.hasNext()){ Object[] row = (Object[])it.next(); for(int i = 0; i < row.length;i++){ System.out.print(row[i]); System.out.println(); } }

Read at Hibernate Projections.

Thanks



December 2, 2010 at 7:54 PM


Hi,

Here is the code:

   List list = crit.list();
      Iterator it = list.iterator();
      if(!it.hasNext()){
        System.out.println("No any data!");
      }
      else{
        while(it.hasNext()){
          Object[] row = (Object[])it.next();
          for(int i = 0; i < row.length;i++){
            System.out.print(row[i]);
            System.out.println();
          }
        }
      }

Thanks



Related Tutorials/Questions & Answers:
how to iterate hibernate object
how to iterate hibernate object  am just learning hibernate .by the hibernate am getting one list to display a grid(grid has 5 column). now i want to iterate one only column value to calculate total of that particular column. how
How to iterate over a checkbox group
How to iterate over a checkbox group  Hi. I am new to using JQuery and would much appreciate your help. I have a form on which I've created 5..." groups. My plan of attack was to iterate over the MASTER checkbox group
Advertisements
Hibernate criteria - how to use criteria to return only one element of an object instead the entire object.
Hibernate criteria - how to use criteria to return only one element of an object instead the entire object.  How to use criteria to return only one element of an object instead the entire object?   You can use
Persist a List Object in Hibernate - Hibernate
Persist a List Object in Hibernate   Hi All, I have a query on hibernate. How to persist a List object in Hibernate ? Can you give me...()){ Object[] row = (Object[])it.next(); for(int i = 0; i <
object chaining? - Hibernate
object chaining?  daoobject.getsession().begainTransaction; can any one explain the code, i am not understanding this line when iam working with swt and hibernate
what is object chaining? - Hibernate
what is object chaining?   daoobject.getsession().begainTransaction; can any one explain the code, i am understanding this line when iam working with swt and hibernate
Logic Iterate.
Logic Iterate.  I have one doubt about logic:iterate. I use text feild inside of logic:iterate , there is possible will generate N no of rows (text feild) inside of iterate. my doubt is how to get the Paritcular rows text
hibernate object states and life cycle
hibernate object states and life cycle  I am bit confused in between the hibernate states and it's life cycle. Can you please explain this also? also explain the persistent, detached and transient object states.Thanks
How to handle the list dynamically in struts inside logic:iterate tag
How to handle the list dynamically in struts inside logic:iterate tag  I am having following code in JSP <table> <tr> <logic:iterate name="loginForm" id="inutParams" property="inutParams" indexId="i"> <
Logic Iterate.
Logic Iterate.  logic iterate Struts I have one doubt about logic:iterate. I use text field inside of logic:iterate , there is possible will generate N no of rows (text field) inside of iterate. my doubt is how to get
Iterate a List in Java
Iterate a List in Java In this tutorial I will show you how you can iterate... to iterate a List in Java In java a list object can be iterated in following... to iterate a list object: import java.util.Iterator; import java.util.List
Iterate Tag used with a Map.
Iterate Tag used with a Map.  How Iterate Tag used with a Map
How to disable an HTML object?
How to disable an HTML object?  How to disable an HTML object
How to sort json object?
How to sort json object?  I've been looking for a while and want a way to sort a JSON object like this: {"results": [ { "layerId": 5, "layerName": "Pharmaceutical Entities", "attributes": { "OBJECTID": "35
logic-iterate
logic-iterate  in my code i am using for-each loop for displaying data i want use tag to display data how to use plase help me <%@ page import="java.sql.*" %> <%String[] id = (String[])session.getAttribute("ids
Collection Iterate Example
Collection Iterate Example       In this section, you will get the detailed explanation about the hasNext() method of interface Iterator. We are going to use hasNext() method
logic iterate tag - Struts
logic iterate tag  Hey I am displaying the values in a jsp called categoryView.jsp using logic iterate tag as Now properties... CategoryForm.java to ViewCategoryForm.java. How do I separate both of the form beans
how to configure the hibernate in netbean
how to configure the hibernate in netbean  how to configure the hibernate in netbean 6.5
How to revert back ServletInputStream object after reading once. - JSP-Servlet
. My Q is how can I iterate request object twice? How we can revert back...How to revert back ServletInputStream object after reading once.  Hi.... To read data from request object using ServletInputStream. Now I want to iterate same
Struts logic iterate
with iterate name= "listM". Another table also opens. So please tell me how can i... iterate <%@taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>...; <body> <h1> Search </h1> <logic:iterate name
How to make focus on an object, make focus on an object, focus on an object
How to make focus on an object       This example will teach you to make focus on the object so follow...: Choose Polygonal lasso tool (L key) to make selection of the object. Blur
How to run? - Hibernate
friends are told hibernate is a new entry to Java. so plz try to tell how to use Hibernate code in my application?  Hi friend, Hinernate : Hibernate...How to run?  Hiiiiiiiiiiiii friend.. i am Magesh
How will you configure Hibernate?
How will you configure Hibernate?  Hi, How will you configure Hibernate? Thanks
How to find a servlet object by name?
How to find a servlet object by name?  How can we locate a servlet object in the code by it's object name?   A. In web.xml you map servlet... by calling getServletNames on the ServletContext object. ServletContext is available
how to Integrate MULE and HIBERNATE - Hibernate
how to Integrate MULE and HIBERNATE  hi, i am having a simple JSP... as webservice. Hibernate is used to talk with DB. I have used Spring framework to generate beans for all my java classes. but i am not able to integrate MULE with Hibernate
how to edit a record in hibernate?
how to edit a record in hibernate?  how to edit a record in hibernate?   Hi Friend, Please visit the following link: Hibernate Tutorials Thanks   Hi Friend, Please visit the following link: Hibernate
How to learn Hibernate?
How to learn Hibernate?  I am beginner in Hibernate. Now I want to learn Hibernate. Can anyone explain me how to learn Hibernate from scratch... learn the complete Hibernate. Check the tutorial Hibernate examples and articles
How to calculate the average in Hibernate?
How to calculate the average in Hibernate?  Hi, I have to calculate the average in Hibernate. How to calculate the average in Hibernate? Thanks   Hi, You can use the project in Hibernate. Here is the example code
How to update table in Hibernate
How to update table in Hibernate  Hi, I have a table in database that has two fields in it. Student Name and ID, can anyone explain me how to update these tables in Hibernate. Thanks.   Update table query in Hibernate
how many ways are there to invoke a servlet object?
how many ways are there to invoke a servlet object?  how many ways are there to invoke a servlet object
In Java how to get size of class and object?
In Java how to get size of class and object?  In Java how to get size of class and object
Advertisements
 

 

 

DMCA.com