[Hibernate] crawling strategy

A distinction between delay and immediately retrieve

  • Retrieving immediately:
    • When you execute a line of code, and immediately issue SQL statements to query.
    • get()
  • Delay Search:
    • When we execute a line of code will not immediately issue SQL query statements. SQL statement will be sent when the real use of the object.
    • load();

Second, the class-level search and retrieval association level

  • Class level of Search:
    • Lazy arranged on <class> tag
  • The associated level of Search:

    • / Above lazy.
  • When an object query, the query whether the associated object?

  • When associated with the query object is retrieved using the delay?

  • From one of a plurality of associated one of:

    • fetch: control the type of sql statement

      • join: send SQL queries associated object pressing the left outer join .fetch = "join" so lazy ignored.
      • select: defaults, sending multiple SQL query associated objects.
      • subselect: Send subquery associated objects (need to use the Query interface test).
    • lazy: retrieving the object associated control whether to use delay.

      • true: The default value associated with the query to retrieve objects when using delay
      • false: When a query object is not associated with the use of delayed retrieval.
      • extra: its laziness.
    • If fetch is the case of join, lazy property is ignored.

  • In the multi-party associated with a party:

    • fetch: control SQL statements sent format
    • join: send an urgent left outer join query associated object .fetch = "join", lay property is ignored.
    • select: send multiple SQL to retrieve associated objects.
    • lazy: when the associated object retrieved, whether to use delay
    • false: do not delay
    • proxy:. Use agent retrieves the order amount when the customer whether to immediately retrieve the mapping file by the Customer object The lazy attribute to decide.
    • no-proxy: do not use a proxy

Guess you like

Origin www.cnblogs.com/haoworld/p/hibernate-zhua-qu-ce-lue.html