hibernate query

User's query

   * Single table query

       * There are too few fields to display on the page compared to the database

           select new Person(pid,pname) from Person;

       * The fields to be displayed on the page are similar to the fields of the database

           from Person

   * Multi-table query

       Customer and Order Form

        * Display customer information in a page, there is a hyperlink in the customer information, click on the hyperlink

           Display information about the customer's order in another page

           *  后台:"from Customer"

              Because the default loading mode for one-to-many collections is lazy loading, when the above hql statement is executed

              The customer's order is not loaded, so only customer information can be loaded on the first page

           * When the hyperlink is clicked, the background "from Order o where o.customer.cid=?"

              Using such an hql statement, you can load order information

        * Display customer information and customer order information in one page

           Using an eager left outer join, only one SQL statement is issued

       Three tables (one-to-many, many-to-many) can be done by pressing the left outer join of the three tables

       If there are multiple tables, the fields on the page are too different from the fields in the database

           "from User";

           user.getDepartment().getDname()

           user.getPosts()

             pname

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326646983&siteId=291194637