What is the difference between hibernate learning list and iterator? one-to-many bidirectional Association Configuration

Source: Internet
Author: User

1. for the list () method and iterator () method of the Query interface, you can obtain the Query object, but list () every object returned by the method is complete (each attribute in the object is filled with fields in the table), and the object returned by the iterator () method only contains the primary key value (identifier ), only when operating on objects in iterator (), hibernate will send an SQL statement to the database again to obtain the attribute value of this object. 2. One-to-multiple bidirectional Association configuration. Relationship between customer and order: [java] public class Customer {private Long id; private String name; private Set <Order> orders; // One to multiple, this variable can be used to reference the corresponding Order set object... Get/set Method omitted} [java] public class Order {private Long id; private String orderNumber; private Customer customer; // multiple-to-one, this variable can be used to reference the associated customer object... Get/set Method omitted} Customer. hbm. xml [html]

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.