In nhib.pdf, The hql language is used for queries. This oo-colored query method is different from the traditional SQL query method. This can be seen from its syntax: http://www.hibernate.org/documentation/hqlbnf.
A relatively simple queryCodeAs follows:
Ilist userlist = session. Find ("from testmssql. Student as student where student. Name =? "," James ", nhib.pdf. nhib.pdf. String );
The code above indicates that students whose names are "Zhang San" are queried from the testmssql. Student object table.
If the connection query between multiple objects is involved, the Code is as follows:
Ilist userlist = session. Find ("from student s left outer join S. Teacher as t where T. teachername = 'Tom '");
Query the students whose instructor name is "Tom.
During the test, I bound the returned results to the DataGrid, and the results showed normal. However, the following method is problematic:
Ilist userlist = session. Find ("select S. Name, T. teachername from student s left outer join S. Teacher as t where T. teachername = 'ee '");
When bound to the DataGrid, the attribute of each object in the ilist is displayed, such as rank and isreadonly, instead of the name and teachername required in the script. Why?
Two ilist values are compared carefully. If select is not used, a student object is returned. Otherwise, an array of objects (object []) is returned. therefore, an error occurred while binding to the DataGrid.
The hql language has the following syntax: New classname open selectedpropertieslist close
That is, you can construct the queried attributes into a new class, for example:
Select New studentinfo (S. name, T. teachername) from student s left Outer Join s. teacher as t where T. teachername = 'ee ', but when I try again, I find that the new class must be persistent, that is, studentinfo AND ITS HBM must be implemented. XML file, which is meaningless.
There are too few nhib.pdf documents and they can only be used by themselves. Now I have to start reading hibernate documents.