日韩久久久精品,亚洲精品久久久久久久久久久,亚洲欧美一区二区三区国产精品 ,一区二区福利

Hibernate檢索策略學習之--批量加載

系統 1913 0

所謂批量加載,即把原本要發送的SQL分批統一發送,比如說原本要發送100條SQL,如果設置batch-size=3,則只需要發送100/3+1=34條,可以提高效率

批量加載分為延遲加載和立即加載,先說立即加在

首先建立測試數據庫

?



CREATE ? TABLE ?certificate?(
??id?
varchar ( 100 )? NOT ? NULL ? default ? '' ,
??description?
varchar ( 100 )? default ? '' ,
??
PRIMARY ? KEY ??(id)
);





CREATE ? TABLE ?student?(
??team_id?
varchar ( 100 )? default ? '' ,
??id?
varchar ( 100 )? NOT ? NULL ? default ? '' ,
??name?
varchar ( 20 )? default ? '' ,
??cardId?
varchar ( 20 )? NOT ? NULL ? default ? '' ,
??age?
int ( 11 )? default ? ' 0 ' ,
??
PRIMARY ? KEY ??(id)
);


CREATE ? TABLE ?team?(
??id?
varchar ( 100 )? NOT ? NULL ? default ? '' ,
??teamName?
varchar ( 100 )? default ? '' ,
??
PRIMARY ? KEY ??(id)
);


INSERT ? INTO ?student? VALUES ?
(
' 5 ' , ' 1 ' , ' spark ' , ' 200211332 ' , 13 ),
(
' 4 ' , ' 2 ' , ' jerry ' , ' 200233332 ' , 23 ),
(
' 3 ' , ' 3 ' , ' adidas ' , ' 200231332 ' , 33 ),
(
' 2 ' , ' 4 ' , ' zhouxingchi ' , ' 200231132 ' , 43 ),
(
' 1 ' , ' 5 ' , ' tomclus ' , ' 200512345 ' , 53 ),
(
' 1 ' , ' 6 ' , ' tom ' , ' 200511345 ' , 63 );

INSERT ? INTO ?team? VALUES ?
(
' 5 ' , ' team5 ' ),
(
' 4 ' , ' team4 ' ),
(
' 3 ' , ' team3 ' ),
(
' 2 ' , ' team2 ' ),
(
' 1 ' , ' team1 ' );

INSERT ? INTO ?certificate? VALUES ?
(
' 1 ' , ' card1 ' ),
(
' 2 ' , ' card2 ' ),
(
' 3 ' , ' card3 ' ),
(
' 4 ' , ' card4 ' ),
(
' 5 ' , ' card5 ' ),
(
' 6 ' , ' card6 ' );

?

建立POJO對象

?

package ?Search.immediately;

public ? class ?Certificate?......... ... {
????
private ?String?id;
????
private ?String?description;
????
private ?Student?stu;

????
public ?Student?getStu()?......... ... {
????????
return ?stu;
????}


????
public ? void ?setStu(Student?stu)?......... ... {
????????
this .stu? = ?stu;
????}



????
public ?String?getDescription()?......... ... {
????????
return ?description;
????}


????
public ? void ?setDescription(String?description)?......... ... {
????????
this .description? = ?description;
????}


????
public ?String?getId()?......... ... {
????????
return ?id;
????}


????
public ? void ?setId(String?id)?......... ... {
????????
this .id? = ?id;
????}

}




package ?Search.immediately;

import ?java.util.HashSet;
import ?java.util.Set;


public ? class ?Team?......... ... {
????
private ?String?id;
????
private ?Set?students = new ?HashSet();
????
private ?String?teamName;
????
private ?Set?tests;
??
????
public ?Set?getTests()?......... ... {
????????
return ?tests;
????}

?
????
public ? void ?setTests(Set?tests)?......... ... {
????????
this .tests? = ?tests;
????}


????
public ?String?getId()?......... ... {
????????
return ?id;
????}


????
public ? void ?setId(String?id)?......... ... {
????????
this .id? = ?id;
????}


????
public ?String?getTeamName()?......... ... {
????????
return ?teamName;
????}


????
public ? void ?setTeamName(String?name)?......... ... {
????????
this .teamName? = ?name;
????}


????
public ?Set?getStudents()?......... ... {
????????
return ?students;
????}


????
public ? void ?setStudents(Set?students)?......... ... {
????????
this .students? = ?students;
????}

}




package ?Search.immediately;

public ? class ?Certificate?......... ... {
????
private ?String?id;
????
private ?String?description;
????
private ?Student?stu;

????
public ?Student?getStu()?......... ... {
????????
return ?stu;
????}


????
public ? void ?setStu(Student?stu)?......... ... {
????????
this .stu? = ?stu;
????}



????
public ?String?getDescription()?......... ... {
????????
return ?description;
????}


????
public ? void ?setDescription(String?description)?......... ... {
????????
this .description? = ?description;
????}


????
public ?String?getId()?......... ... {
????????
return ?id;
????}

Hibernate檢索策略學習之--批量加載


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 手游| 普安县| 大庆市| 永嘉县| 新野县| 达尔| 天长市| 武宁县| 周至县| 乳山市| 万年县| 光山县| 海盐县| 五常市| 周至县| 漳州市| 拉孜县| 确山县| 吉木乃县| 嘉禾县| 体育| 枣阳市| 玛多县| 嘉峪关市| 青阳县| 东乡县| 江陵县| 棋牌| 辰溪县| 岑巩县| 中江县| 皋兰县| 习水县| 石阡县| 会东县| 宁国市| 通道| 平阴县| 泾阳县| 宁都县| 佛教|