gpt4 book ai didi

mysql - 如何将hibernate查询转换为sql

转载 作者:行者123 更新时间:2023-11-29 19:14:27 26 4
gpt4 key购买 nike

我的查询是

select distinct quoteRequest 
from QuoteRequest quoteRequest
left join quoteRequest.quotationRequestItems quotationRequestItems
left join quotationRequestItems.localSite localSite
left join quotationRequestItems.quotes quotes
left join quotes.approvalLevel quoteApprovalLevel
left join quotationRequestItems.orders orders
left join orders.approvalLevel orderApprovalLevel
left join quotationRequestItems.disconnectionDetail disconnectionDetail
where ( quoteRequest.contractingPartyIc01 IN ('123456','673542') )
and ( delegatedOwner_ftid = 'mayank' )
and quoteRequest.archived = 0
and quoteRequest.template = 0
order by quoteRequest.updateDate desc

我想将其转换为sql..

我已经尝试过

String queryString1 = query.unwrap(org.hibernate.Query.class).getQueryString();

show_sql = true aswell;

但是我没有得到正确的 sql 查询..有人可以帮忙吗。

show_sql 产生以下查询,但我无法理解 where 子句:

 select
quotationr0_.quoteRequestId as quoteRe16_0_7_,
quotationr0_.id as id7_,
quotationr0_.id as id2_6_,
quotationr0_.billingInSameCountry as billingI2_2_6_,
quotationr0_.creationDate as creation3_2_6_,
quotationr0_.currencyCode as currency4_2_6_,
quotationr0_.deliverySite_id as deliver11_2_6_,
quotationr0_.disconnectionDetail_id as disconn12_2_6_,
quotationr0_.existingSite_id as existin13_2_6_,
quotationr0_.localSite_id as localSite14_2_6_,
quotationr0_.offerInstance_id as offerIn15_2_6_,
quotationr0_.preferredBillingCity as preferre5_2_6_,
quotationr0_.preferredBillingCountryCode as preferre6_2_6_,
quotationr0_.preferredBillingCurrencyCode as preferre7_2_6_,
quotationr0_.retainExistingBillingPreference as retainEx8_2_6_,
quotationr0_.status as status2_6_,
quotationr0_.updateDate as updateDate2_6_,
site1_.id as id5_0_,
site1_.address1 as address2_5_0_,
site1_.address2 as address3_5_0_,
site1_.address3 as address4_5_0_,
site1_.city as city5_0_,
site1_.comment as comment5_0_,
site1_.companyName as companyN7_5_0_,
site1_.coreAddressId as coreAddr8_5_0_,
site1_.coreSiteId as coreSiteId5_0_,
site1_.countryCode3 as country10_5_0_,
site1_.countryName as country11_5_0_,
site1_.customerSiteName as custome12_5_0_,
site1_.existingSite as existin13_5_0_,
site1_.fetchedFromCore as fetched14_5_0_,
site1_.floorNumber as floorNu15_5_0_,
site1_.orangeSiteRef as orangeS16_5_0_,
site1_.phone as phone5_0_,
site1_.postalCode as postalCode5_0_,
site1_.previousGoldOrderNumber as previou19_5_0_,
site1_.primaryContact_id as primary24_5_0_,
site1_.roomNumber as roomNumber5_0_,
site1_.secondaryContact_id as seconda25_5_0_,
site1_.siteAccess as siteAccess5_0_,
site1_.siteModified as siteMod22_5_0_,
site1_.siteModifiedFlags_id as siteMod26_5_0_,
site1_.state as state5_0_,
sitemodifi2_.id as id21_1_,
sitemodifi2_.address1 as address2_21_1_,
sitemodifi2_.address2 as address3_21_1_,
sitemodifi2_.address3 as address4_21_1_,
sitemodifi2_.city as city21_1_,
sitemodifi2_.comment as comment21_1_,
sitemodifi2_.companyName as companyN7_21_1_,
sitemodifi2_.countryName as countryN8_21_1_,
sitemodifi2_.customerSiteName as customer9_21_1_,
sitemodifi2_.floorNumber as floorNu10_21_1_,
sitemodifi2_.phone as phone21_1_,
sitemodifi2_.postalCode as postalCode21_1_,
sitemodifi2_.roomNumber as roomNumber21_1_,
sitemodifi2_.siteAccess as siteAccess21_1_,
sitemodifi2_.state as state21_1_,
disconnect3_.id as id24_2_,
disconnect3_.additionalServiceInfo as addition2_24_2_,
disconnect3_.backupLineIncluded as backupLi3_24_2_,
disconnect3_.billingReference as billingR4_24_2_,
disconnect3_.dna as dna24_2_,
disconnect3_.externalCustomerReference as external6_24_2_,
disconnect3_.isDisconnectVoiceServices as isDiscon7_24_2_,
disconnect3_.previousOrderReference as previous8_24_2_,
disconnect3_.requestedDisconnectDate as requeste9_24_2_,
disconnect3_.routerName as routerName24_2_,
disconnect3_.serviceType as service11_24_2_,
disconnect3_.voiceServiceToBeDisconnected as voiceSe12_24_2_,
site4_.id as id5_3_,
site4_.address1 as address2_5_3_,
site4_.address2 as address3_5_3_,
site4_.address3 as address4_5_3_,
site4_.city as city5_3_,
site4_.comment as comment5_3_,
site4_.companyName as companyN7_5_3_,
site4_.coreAddressId as coreAddr8_5_3_,
site4_.coreSiteId as coreSiteId5_3_,
site4_.countryCode3 as country10_5_3_,
site4_.countryName as country11_5_3_,
site4_.customerSiteName as custome12_5_3_,
site4_.existingSite as existin13_5_3_,
site4_.fetchedFromCore as fetched14_5_3_,
site4_.floorNumber as floorNu15_5_3_,
site4_.orangeSiteRef as orangeS16_5_3_,
site4_.phone as phone5_3_,
site4_.postalCode as postalCode5_3_,
site4_.previousGoldOrderNumber as previou19_5_3_,
site4_.primaryContact_id as primary24_5_3_,
site4_.roomNumber as roomNumber5_3_,
site4_.secondaryContact_id as seconda25_5_3_,
site4_.siteAccess as siteAccess5_3_,
site4_.siteModified as siteMod22_5_3_,
site4_.siteModifiedFlags_id as siteMod26_5_3_,
site4_.state as state5_3_,
site5_.id as id5_4_,
site5_.address1 as address2_5_4_,
site5_.address2 as address3_5_4_,
site5_.address3 as address4_5_4_,
site5_.city as city5_4_,
site5_.comment as comment5_4_,
site5_.companyName as companyN7_5_4_,
site5_.coreAddressId as coreAddr8_5_4_,
site5_.coreSiteId as coreSiteId5_4_,
site5_.countryCode3 as country10_5_4_,
site5_.countryName as country11_5_4_,
site5_.customerSiteName as custome12_5_4_,
site5_.existingSite as existin13_5_4_,
site5_.fetchedFromCore as fetched14_5_4_,
site5_.floorNumber as floorNu15_5_4_,
site5_.orangeSiteRef as orangeS16_5_4_,
site5_.phone as phone5_4_,
site5_.postalCode as postalCode5_4_,
site5_.previousGoldOrderNumber as previou19_5_4_,
site5_.primaryContact_id as primary24_5_4_,
site5_.roomNumber as roomNumber5_4_,
site5_.secondaryContact_id as seconda25_5_4_,
site5_.siteAccess as siteAccess5_4_,
site5_.siteModified as siteMod22_5_4_,
site5_.siteModifiedFlags_id as siteMod26_5_4_,
site5_.state as state5_4_,
offerinsta6_.id as id1_5_,
offerinsta6_.name as name1_5_,
offerinsta6_.oCatId as oCatId1_5_,
offerinsta6_.offerCatalogId as offerCat4_1_5_,
offerinsta6_.productToDisplay as productT5_1_5_,
offerinsta6_.qrfComment as qrfComment1_5_,
offerinsta6_.qrfContent as qrfContent1_5_,
offerinsta6_.qrfReference as qrfRefer8_1_5_
from
oqt_quotation_request_item quotationr0_
left outer join
oqt_site site1_
on quotationr0_.deliverySite_id=site1_.id
left outer join
oqt_site_modification_status sitemodifi2_
on site1_.siteModifiedFlags_id=sitemodifi2_.id
left outer join
oqt_disconnection_detail disconnect3_
on quotationr0_.disconnectionDetail_id=disconnect3_.id
left outer join
oqt_site site4_
on quotationr0_.existingSite_id=site4_.id
left outer join
oqt_site site5_
on quotationr0_.localSite_id=site5_.id
left outer join
oqt_offer_instance offerinsta6_
on quotationr0_.offerInstance_id=offerinsta6_.id
where
quotationr0_.quoteRequestId in (
?, ?, ?, ?, ?, ?, ?, ?, ?, ?
)

最佳答案

一般来说,要查看翻译后的查询,您可以:

  1. 更改日志记录 org.hibernate.SQL=DEBUG。
  2. 使用 Intellij IDEA JPA 控制台

关于mysql - 如何将hibernate查询转换为sql,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42827206/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com