簡體   English   中英

為什么冬眠並沒有使多對多的左連接

[英]why hibernate did't make left join on many to one

我有2表關系類型多對一。 我想看到休眠生成左聯接

配置模型類

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "stationid")
@Fetch(FetchMode.JOIN)
Station station;

休眠代碼中的此示例sql

 select
    tollopn0_.dt as dt7_0_,
    tollopn0_.shift as shift7_0_,
    tollopn0_.stationid as stationid7_0_,
    tollopn0_.createTime as createTime7_0_,
    tollopn0_.creator as creator7_0_,
    tollopn0_.remarsk as remarsk7_0_,
    tollopn0_.updateTime as updateTime7_0_,
    tollopn0_.updator as updator7_0_,
    tollopn0_.line as line7_0_,
    tollopn0_.rev_cash as rev10_7_0_,
    tollopn0_.rev_etc as rev11_7_0_,
    tollopn0_.sold_bail as sold12_7_0_,
    tollopn0_.sold_changeEasyPass as sold13_7_0_,
    tollopn0_.sold_changeSmartCard as sold14_7_0_,
    tollopn0_.sold_fee as sold15_7_0_,
    tollopn0_.sold_qty as sold16_7_0_,
    tollopn0_.sold_reserv as sold17_7_0_,
    tollopn0_.trf_etc as trf19_7_0_,
    tollopn0_.trf_trf1 as trf20_7_0_,
    tollopn0_.trf_trf2 as trf21_7_0_,
    tollopn0_.trf_trf3 as trf22_7_0_,
    tollopn0_.trf_trf4 as trf23_7_0_,
    tollopn0_.uap_causeOther as uap24_7_0_,
    tollopn0_.uap_causeOverPAD as uap25_7_0_,
    tollopn0_.uap_causeRemarsk as uap26_7_0_,
    tollopn0_.uap_causeSeeError as uap27_7_0_,
    tollopn0_.uap_nocCard as uap28_7_0_,
    tollopn0_.uap_nocMotorcycle as uap29_7_0_,
    tollopn0_.uap_nocOther as uap30_7_0_,
    tollopn0_.uap_nocOutOfCard as uap31_7_0_,
    tollopn0_.uap_nocRemarsk as uap32_7_0_,
    tollopn0_.uap_nocSoildier as uap33_7_0_,
    tollopn0_.uap_t05Ambulance as uap34_7_0_,
    tollopn0_.uap_t05FireTruck as uap35_7_0_,
    tollopn0_.uap_t05King as uap36_7_0_,
    tollopn0_.uap_t05LuangRoyal as uap37_7_0_,
    tollopn0_.uap_t05Mailcoaches as uap38_7_0_,
    tollopn0_.uap_t05Military as uap39_7_0_,
    tollopn0_.uap_t05PoliceCar as uap40_7_0_,
    tollopn0_.uap_t05PoliceMotorcycle as uap41_7_0_,
    tollopn0_.uap_t50Other as uap42_7_0_,
    tollopn0_.uap_uapT50Remarsk as uap43_7_0_,
    tollopn0_.uap_uap10Bath as uap44_7_0_,
    tollopn0_.uap_uap20Bath as uap45_7_0_,
    tollopn0_.uap_uap5Bath as uap46_7_0_,
    tollopn0_.uap_uapCanKept10Bath as uap47_7_0_,
    tollopn0_.uap_uapCanKept20Bath as uap48_7_0_,
    tollopn0_.uap_uapCanKept5Bath as uap49_7_0_,
    tollopn0_.uap_uapLoyal as uap50_7_0_,
    tollopn0_.uap_uapMotorcycle as uap51_7_0_,
    tollopn0_.uap_uapOther as uap52_7_0_,
    tollopn0_.uap_uapPolice as uap53_7_0_,
    tollopn0_.uap_uapRemarsk as uap54_7_0_,
    tollopn0_.uap_uapSoildier as uap55_7_0_,
    tollopn0_.cpn_sold_c60 as cpn66_7_0_,
    tollopn0_.cpn_sold_c75 as cpn67_7_0_,
    tollopn0_.cpn_used_c30 as cpn68_7_0_,
    tollopn0_.cpn_used_c40 as cpn69_7_0_,
    tollopn0_.cpn_used_c42 as cpn70_7_0_,
    tollopn0_.cpn_used_c45 as cpn71_7_0_,
    tollopn0_.cpn_used_c50 as cpn72_7_0_,
    tollopn0_.cpn_used_c53 as cpn73_7_0_,
    tollopn0_.cpn_used_c55 as cpn74_7_0_,
    tollopn0_.cpn_used_c60 as cpn75_7_0_,
    tollopn0_.cpn_used_c64 as cpn76_7_0_,
    tollopn0_.cpn_used_c70 as cpn77_7_0_,
    tollopn0_.cpn_used_c75 as cpn78_7_0_,
    tollopn0_.rev_cpn as rev79_7_0_ 
from
    trf_trx_toll tollopn0_ 
where
    tollopn0_.dt=? 
    and tollopn0_.shift=? 
    and tollopn0_.stationid=? 
    and tollopn0_.linetype='OPN'

11:37:56,588 TRACE BasicBinder:82-綁定參數[1]為[TIMESTAMP]-星期四,八月06 00:00:00 ICT 2015 11:37:56,589 TRACE BasicBinder:82-綁定參數[2]為[INTEGER]- 1 11:37:56,589 TRACE BasicBinder:82-綁定參數[3]為[VARCHAR]-111

Hibernate: 
select
    station0_.id as id5_0_,
    station0_.lineid as lineid5_0_,
    station0_.name as name5_0_,
    station0_.revetc as revetc5_0_ 
from
    trf_mst_station station0_ 
where
    station0_.id=?

11:37:56,570 TRACE BasicBinder:82-綁定參數[1]為[VARCHAR]-111

您說過必須使用以下方式延遲加載關聯

fetch = FetchType.LAZY

因此,Hibernate延遲獲取關聯。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM