Today I did a function of using SQL statements for table-link queries in Hibernate, and the resulting properties are from fields in two tables. The following methods are logged for the result set traversal.
The SQL statement is not written. Some of the code is as follows:
list<course_material> list =NewArraylist<course_material>(); @SuppressWarnings ("Rawtypes") List accountlist=query.list (); if(Accountlist.size () >0) {object[] objects; course_material cm=Newcourse_material (); for(intI=0; I<accountlist.size (); i++) {Objects= (object[]) accountlist.Get(i);//converting a result set to an objects arrayCm.setnumber (Integer.parseint (objects[0].tostring ())); Cm.setcoursexuhao (Integer.parseint (objects[1].tostring ())); Cm.setcoursename (objects[2].tostring ()); Cm.setclassname (objects[3].tostring ()); Cm.setdatetype (objects[4].tostring ()); Cm.setattachfile (objects[5].tostring ()); Cm.setattachname (objects[6].tostring ()); List.add (CM); } }
The above is the method of generating a list collection of the resulting results.
Hibernate using SQL statements for table-link queries, and for the result set traversal method