I have this code Segment that always executes Succesfully
String d="select HistAt as HistAt,RId as RId from tblrecord"; SQLQuery q=session.createSQLQuery(d); q.addScalar("HistAt",Hibernate.STRING); q.addScalar("RId",Hibernate.STRING); List results=q.list();int i=0;
Pls how do i retrieve the results from the List
posted 9 years ago
When hibernate invokes a sql query, it returns a collection from the list() method.
this collection will contain an array of objects, the size of the array of objects will be the number of bound scalar parameterss you have defined (in your case, 2)
the following code snippet is what i use to unroll the list of array of objects into a different collection, it is a collection that is useful by me.
you can also see i was using debug statements to figure out what class types were being returned from the elements inside the array of objects from the sql query scalars. this will be what ever type they are mapped as in hibernate, in my case they were String.
Error: Keyboard not attached. Press F1 to continue.