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 to do this....

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
how to iterate a map in java using for each
how to iterate a map in java using for each  Hi, I have a HashMap in Java and there is need to iterate all the items. how to iterate a map in java using for each? Thanks   Hi, This example is using the stream
how to iterate a map in java using for each
how to iterate a map in java using for each  Hi, I have a HashMap in Java and there is need to iterate all the items. how to iterate a map in java using for each? Thanks   Hi, This example is using the stream
how to iterate a map in java using for each
how to iterate a map in java using for each  Hi, I have a HashMap in Java and there is need to iterate all the items. how to iterate a map in java using for each? Thanks   Hi, This example is using the stream
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
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
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
How to disable an HTML object?
How to disable an HTML object?  How to disable an HTML object
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 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"> <
ModuleNotFoundError: No module named 'iterate'
'iterate' How to remove the ModuleNotFoundError: No module named 'iterate...ModuleNotFoundError: No module named 'iterate'  Hi, My Python... to install padas library. You can install iterate python with following command
ModuleNotFoundError: No module named 'iterate'
'iterate' How to remove the ModuleNotFoundError: No module named 'iterate...ModuleNotFoundError: No module named 'iterate'  Hi, My Python... to install padas library. You can install iterate python with following command
JavaScript Iterate JOSN array.
JavaScript Iterate JOSN array.  Hi, I have key value pair of key value in JSON object. How to iterate it? Thanks   Hi, Here is example...;body> <p>JavaScript Iterate JOSN array.</p> </body> </html>
JavaScript Iterate JOSN array.
JavaScript Iterate JOSN array.  Hi, I have key value pair of key value in JSON object. How to iterate it? Thanks   Hi, Here is example...;body> <p>JavaScript Iterate JOSN array.</p> </body> </html>
JavaScript Iterate JOSN array.
JavaScript Iterate JOSN array.  Hi, I have key value pair of key value in JSON object. How to iterate it? Thanks   Hi, Here is example...;body> <p>JavaScript Iterate JOSN array.</p> </body> </html>
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
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
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... of the object. ADS_TO_REPLACE_2 Blur effect: Go to Filter menu > Blur >Apply
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
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
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
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
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
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
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
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
How to delete objects using Hibernate?
How to delete objects using Hibernate?  Hi, How to delete objects using Hibernate? I want to delete an object (record) in table. Thanks   Hi, Hibernate Session API provides function to delete object. For deleting
object
object  is it possible to create object in the same class..?.   Yes, you can. class CreateObject { CreateObject(){ System.out.println("I have an object."); } public static void main(String[] args
how to make an unreachable object as reachable - Java Beginners
how to make an unreachable object as reachable  i know that an object is garbagecollected when it is unreachable to the programmer but my question is how that unreachable object which was garbage collected will become
How to change object item to integer item
How to change object item to integer item  How to change objectitem to integer item?thankyou
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 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 to use an object properties in jsp page
How to use an object properties in jsp page  I have a arraylist of objects 'User' populated using struts 2 action class while loading that jsp page... of hardcoded value 'AMIT' I want to use value of User object. How can I do it? Please
how to get session object in simple java class??
how to get session object in simple java class??  i am fallowing... into session. so, please tell me, how to get the session object (GroupPojo) in a simple... the value to GroupPojo.java and set this pojo object into session. sending control
How to limit object creation in Java?
the objects in JVM. In this section you will learn about how a class object creation can.... You will learn how to restrict the object creation of a class. This is a simple...How to limit the max no of objects creation for a class? Yes there is a way
How to limit object creation in Java?
the objects in JVM. In this section you will learn about how a class object creation can.... You will learn how to restrict the object creation of a class. This is a simple...How to limit the max no of objects creation for a class? Yes there is a way
struts logic:iterate tag
struts logic:iterate tag  Hi All, I am writing a look up jsp which is using logc:iterate every thing is fine except this the problem here is unable to go inside the tag. Here is the stack trace I am getting. [#|2010-10-27T00
Iterate list of objects on jsp page
Iterate list of objects on jsp page  Hi, I want to iterate the list of objects on jsp page using custom tags. Can you please give me one link or example? Thanks
How to dynamically build a JSON object with Python
How to dynamically build a JSON object with Python  Hi, I have many..., I want full proof method to make json dynamically with Python. How to do this? How to dynamically build a JSON object with Python? Thanks   Hi
How to dynamically build a JSON object with Python
How to dynamically build a JSON object with Python  Hi, I have many..., I want full proof method to make json dynamically with Python. How to do this? How to dynamically build a JSON object with Python? Thanks   Hi
How will you configure Hibernate?
How will you configure Hibernate?  Hi, How will you configure Hibernate? Thanks
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 can i set an object in focus
how can i set an object in focus  There is a Canvas object in my game and this object is not set in focus, because of this my snake is not moving... is not moving, so someone suggest me that your canvas object is not in focus
<logic:iterate> - Struts
and adding HashMap object in itAs you can see the code in my quesI want to use only

Ads