Query between multiple tables (objects) in nhib.pdf

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.