Detailed usage of the hibernate lazy

hibernate in the use of lazy
lazy, lazy

Lazy is valid: only open in the session when it effective; session after the closure of a lazy no effect.

lazy strategy can be used in:

* <class> Tab: takes the value true / false

* <property> Label, takes the value true / false, this feature requires the class to enhance

* <set> / <list> Other collections, it can be a value of true / false / extra

* <one-to-one> / <many-to-one> Other tab, you can value false / proxy / no-proxy

6.1 get and load the difference between:

* Get does not support lazy loading, and load support.

* When the query does not exist in a particular database the data, get returns null, and the load is thrown.

Class 6.2 (Class) lazy loading:

* Set <class> tab lazy = "true", or keep the default (that is not configured lazy properties)

* If the lazy attribute to true, then use the Load method to load data only when the data actually used in the sql statement will be issued; this may reduce the system overhead.

* / / Will not issue the query sql

System.out.println ("group" + group.getId ());

There is a problem, why not add the primary key issue when the sql statement.

6.3 set (collection) of the lazy: takes the value true, false, extra

* Keep the default set of values ​​on the lazy, the effect of time and lazy = "extra" is basically the same.

* Set a collection of lazy = extra, time effects and lazy attribute default value is essentially the same. However, the value of this property is recommended, because in this case when the statistics become more intelligent. Of course, there is a delay effect.

* Set a collection of lazy = false

true: The default value, which means that only when you call the elements of the collection object to get inside before issuing the query, load the collection of data elements

false: Cancel lazy loading feature that the object is loaded at the same time, it issued a second query to load the associated data collection

extra: a more clever lazy loading strategy that calls a collection of size / contains methods such as time, hibernate

Not to load the entire collection of data, but a smart SQL statement issued to obtain the desired value, only really need to use these elements of the collection object data when it issued a query to load all objects data

6.4 Hibernate single-ended associations, lazy loading strategy: that is, in <one-to-one> / <many-to-one> label can be configured

Lazy loading strategy. Takes the value of: false / proxy / no-proxy

false: Cancel lazy loading strategy, that is loading the object at the same time, send query to load the associated object

proxy: This is for single-ended associations hibernate lazy load the default strategy, that only calls to the method of its associated object when it is actually query the object issuing the query data, its associated object is the proxy class

no-proxy: This lazy loading feature class needs to be enhanced using the no-proxy, the proxy class object is not associated

Note: In the class label does not affect the configuration of the lazy attribute to the associated object!!!

分类:Development 时间:2011-09-08 人气:121
分享到:
blog comments powered by Disqus

相关文章

  • sql statement to update the same data, different data insert 2010-03-09

    Execute a Sql statement, the same vendor_id, inventory_item_id to update, insert new data in different merge into tscs_ems_upload_storage_t a using (select? as vendor_id, ? As inventory_item_id, ? As description,? As unit, ? As quantity,? As check_date, ?

  • Using an sql statement 100,000 live test data 2011-02-22

    Sql-->select rownum as id, to_char(sysdate + rownum / 24 / 3600, 'yyyy-mm-dd hh24:mi:ss') as inc_datetime, trunc(dbms_random.value(0, 100)) as random_id, dbms_random.string('x', 20) random_string from dual connect by level <= 10; Results: 1 200

  • ORACLE SQL statement optimization summarized in 2010-02-23

    ORACLE SQL statement optimization summarized in (1) Select the most efficient sequence table name (only the effective rule-based optimizer): ORACLE parser in accordance with the order processing from right to left in the FROM clause of the table name, FRO

  • Very useful SQL statement optimization 34 2010-05-11

    1) Select the most efficient sequence table name (only the effective rule-based optimizer): ORACLE parser according to the order processing from right to left the table name FROM clause, FROM clause written in the final table (base table driving table) wi

  • Reposted elsewhere - by analyzing the SQL statement execution plan optimization of SQL (summary) 2010-06-30

    By analyzing the SQL statement execution plan optimization of SQL (summary) DBA did almost 7 years, and sentiment among many. In the DBA's daily work, to adjust individual performance to a less challenging when the SQL statement of work. The key lies

  • How to use SQLPLUS of SQL statement (query execution plan tracking) 2010-08-20

    Method 1: autotrace 1, connect sys / password as sysdba, the sys user run $ ORACLE_HOME / sqlplus / admin / plustrce.sql The actual content of this sql as follows: set echo on drop role plustrace; create role plustrace; grant select on v_ $ sesstat to plu

  • To fully optimize your sql statement 2010-10-14

    Not only do we have to write SQL, but also to achieve excellent performance to write SQL statements. (1) choose the most efficient order in the table name (only in the rule-based optimizer valid): Oracle's parser in accordance with the order processin

  • Transfer: oracle sql statement optimization 2010-10-25

    Transfer from: http://www.blogjava.net/killme2008/archive/2007/03/02/101434.html (1) choose the most efficient order in the table name (only in the rule-based optimizer valid): ORACLE parser in accordance with the order processing from right to left in th

  • Analysis using the SQLPLUS SQL statement (query execution plan tracking) 2010-11-10

    Method One: autotrace 1, connect sys / password as sysdba, the sys user run $ ORACLE_HOME / sqlplus / admin / plustrce.sql This sql actual content of the following: set echo on drop role plustrace; create role plustrace; Grant Select on V_ $ sesstat

  • Sybase sql statement used 2010-11-26

    Common sql statements 1. View the version of the database select @ @ version 2. See the operating system parameters of the machine where the database resides exec master .. xp_msver 3. View the database startup parameters sp_configure 4. View the database

iOS 开发

Android 开发

Python 开发

JAVA 开发

开发语言

PHP 开发

Ruby 开发

搜索

前端开发

数据库

开发工具

开放平台

Javascript 开发

.NET 开发

云计算

服务器

Copyright (C) codeweblog.com, All Rights Reserved.

CodeWeblog.com 版权所有 黔ICP备15002463号-1

processed in 0.166 (s). 12 q(s)