- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
正在执行的查询是:
from PurchaseOrder o join fetch o.basket where o.statusE in (:statuses)
PurchaseOrder 中的映射:
@OneToOne(cascade=CascadeType.ALL, fetch = FetchType.LAZY, optional = false)
@Fetch(FetchMode.JOIN)
@JoinColumn(name="basket_id")
public ShoppingBasket getBasket() {
return this.basket;
}
ShoppingBasket 中的映射:
@OneToOne(mappedBy = "basket", cascade=CascadeType.ALL, fetch = FetchType.LAZY, optional = false)
@Fetch(FetchMode.JOIN)
public PurchaseOrder getOrder() {
return order;
}
当该查询被执行时,它被翻译成以下查询:
-- 以下类型的 1 个查询,检索给定状态的所有篮子和订单
select PurchaseOrder.*, ShoppingBasket.* /* changed for simplicity */
from purchaseorders purchaseor0_
inner join shoppingbaskets shoppingba1_ on purchaseor0_.basket_id=shoppingba1_.id
where purchaseor0_.status in (? , ? , ?)
order by purchaseor0_.created DESC limit ?
-- 以下类型的 n 个查询,一个用于检索关联订单的前一个查询的每个篮子结果
select pPurchaseOrder.* /* changed for simplicity */
from purchaseorders purchaseor0_
where purchaseor0_.basket_id=?
我尝试更改抓取策略(我知道无论如何使用 HQL 都会忽略它)、更改抓取计划以及出于绝望的“可选”属性。有什么方法可以让 Hibernate 在单个查询中加载 PurchaseOrders 和关联的 ShoppingBaskets 吗?我是否必须使用字节码检测来实现这一目标?如果是,如何实现?
Hibernate调试日志如下:
DEBUG JDBCTransaction - begin
DEBUG ConnectionManager - opening JDBC connection
DEBUG JDBCTransaction - current autocommit status: true
DEBUG JDBCTransaction - disabling autocommit
DEBUG QueryTranslatorImpl - parse() - HQL: from com.ng.ticketlogic.core.shop.PurchaseOrder o join fetch o.basket where o.statusE in (:statuses) ORDER BY o.created DESC
DEBUG AST - --- HQL AST ---
\-[QUERY] Node: 'query'
+-[SELECT_FROM] Node: 'SELECT_FROM'
| \-[FROM] Node: 'from'
| +-[RANGE] Node: 'RANGE'
| | +-[DOT] Node: '.'
| | | +-[DOT] Node: '.'
| | | | +-[DOT] Node: '.'
| | | | | +-[DOT] Node: '.'
| | | | | | +-[DOT] Node: '.'
| | | | | | | +-[IDENT] Node: 'com'
| | | | | | | \-[IDENT] Node: 'ng'
| | | | | | \-[IDENT] Node: 'ticketlogic'
| | | | | \-[IDENT] Node: 'core'
| | | | \-[IDENT] Node: 'shop'
| | | \-[IDENT] Node: 'PurchaseOrder'
| | \-[ALIAS] Node: 'o'
| \-[JOIN] Node: 'join'
| +-[FETCH] Node: 'fetch'
| \-[DOT] Node: '.'
| +-[IDENT] Node: 'o'
| \-[IDENT] Node: 'basket'
+-[WHERE] Node: 'where'
| \-[IN] Node: 'in'
| +-[DOT] Node: '.'
| | +-[IDENT] Node: 'o'
| | \-[IDENT] Node: 'statusE'
| \-[IN_LIST] Node: 'inList'
| \-[COLON] Node: ':'
| \-[IDENT] Node: 'statuses'
\-[ORDER] Node: 'ORDER'
+-[DOT] Node: '.'
| +-[IDENT] Node: 'o'
| \-[IDENT] Node: 'created'
\-[DESCENDING] Node: 'DESC'
DEBUG ErrorCounter - throwQueryException() : no errors
DEBUG HqlSqlBaseWalker - select << begin [level=1, statement=select]
DEBUG FromElement - FromClause{level=1} : com.ng.ticketlogic.core.shop.PurchaseOrder (o) -> purchaseor0_
DEBUG FromReferenceNode - Resolved : o -> purchaseor0_.id
DEBUG DotNode - getDataType() : basket -> org.hibernate.type.ManyToOneType(com.ng.ticketlogic.core.shop.ShoppingBasket)
DEBUG DotNode - dereferenceEntityJoin() : generating join for basket in com.ng.ticketlogic.core.shop.PurchaseOrder {no alias} parent = [ {null} ]
DEBUG FromElement - FromClause{level=1} : com.ng.ticketlogic.core.shop.ShoppingBasket (no alias) -> shoppingba1_
DEBUG FromClause - addJoinByPathMap() : o.basket -> FromElement{explicit,not a collection join,not a fetch join,fetch non-lazy properties,classAlias=null,role=null,tableName=shoppingbaskets,tableAlias=shoppingba1_,origin=purchaseorders purchaseor0_,columns={purchaseor0_.basket_id ,className=com.ng.ticketlogic.core.shop.ShoppingBasket}}
DEBUG FromReferenceNode - Resolved : o.basket -> purchaseor0_.basket_id
DEBUG HqlSqlWalker - createFromJoinElement() : -- join tree --
\-[JOIN_FRAGMENT] FromElement: 'shoppingbaskets shoppingba1_' FromElement{explicit,not a collection join,fetch join,fetch non-lazy properties,classAlias=null,role=null,tableName=shoppingbaskets,tableAlias=shoppingba1_,origin=purchaseorders purchaseor0_,columns={purchaseor0_.basket_id ,className=com.ng.ticketlogic.core.shop.ShoppingBasket}}
DEBUG FromReferenceNode - Resolved : o -> purchaseor0_.id
DEBUG DotNode - getDataType() : statusE -> org.hibernate.type.CustomType@493744b6
DEBUG FromReferenceNode - Resolved : o.statusE -> purchaseor0_.status
DEBUG FromReferenceNode - Resolved : o -> purchaseor0_.id
DEBUG DotNode - getDataType() : created -> org.hibernate.type.TimestampType@69a4e343
DEBUG FromReferenceNode - Resolved : o.created -> purchaseor0_.created
DEBUG HqlSqlBaseWalker - select : finishing up [level=1, statement=select]
DEBUG HqlSqlWalker - processQuery() : ( SELECT ( FromClause{level=1} ( purchaseorders purchaseor0_ shoppingbaskets shoppingba1_ ) ) ( where ( in ( purchaseor0_.status purchaseor0_.id statusE ) ( inList ? ) ) ) ( ORDER ( purchaseor0_.created purchaseor0_.id created ) DESC ) )
DEBUG HqlSqlWalker - Derived SELECT clause created.
DEBUG JoinProcessor - Using FROM fragment [purchaseorders purchaseor0_]
DEBUG JoinProcessor - Using FROM fragment [inner join shoppingbaskets shoppingba1_ on purchaseor0_.basket_id=shoppingba1_.id]
DEBUG HqlSqlBaseWalker - select >> end [level=1, statement=select]
DEBUG AST - --- SQL AST ---
\-[SELECT] QueryNode: 'SELECT' querySpaces (purchaseorders,shoppingbaskets)
+-[SELECT_CLAUSE] SelectClause: '{derived select clause}'
| +-[SELECT_EXPR] SelectExpressionImpl: 'purchaseor0_.id as id10_0_' {FromElement{explicit,not a collection join,not a fetch join,fetch non-lazy properties,classAlias=o,role=null,tableName=purchaseorders,tableAlias=purchaseor0_,origin=null,columns={,className=com.ng.ticketlogic.core.shop.PurchaseOrder}}}
| +-[SELECT_EXPR] SelectExpressionImpl: 'shoppingba1_.id as id9_1_' {FromElement{explicit,not a collection join,fetch join,fetch non-lazy properties,classAlias=null,role=null,tableName=shoppingbaskets,tableAlias=shoppingba1_,origin=purchaseorders purchaseor0_,columns={purchaseor0_.basket_id ,className=com.ng.ticketlogic.core.shop.ShoppingBasket}}}
| +-[SQL_TOKEN] SqlFragment: 'purchaseor0_.address_id as address17_10_0_, purchaseor0_.affiliate_id as affiliate18_10_0_, purchaseor0_.agreed_cardholder as agreed2_10_0_, purchaseor0_.agreed_terms as agreed3_10_0_, purchaseor0_.alternativeCustomerName as alternat4_10_0_, purchaseor0_.approved as approved10_0_, purchaseor0_.author as author10_0_, purchaseor0_.basket_id as basket19_10_0_, purchaseor0_.card_id as card20_10_0_, purchaseor0_.created as created10_0_, purchaseor0_.editor as editor10_0_, purchaseor0_.groupBookingId as groupBo21_10_0_, purchaseor0_.ip_address as ip9_10_0_, purchaseor0_.linkedOrder as linkedO22_10_0_, purchaseor0_.manual_hold as manual10_10_0_, purchaseor0_.manual_review as manual11_10_0_, purchaseor0_.partner_id as partner23_10_0_, purchaseor0_.platformType as platfor12_10_0_, purchaseor0_.reference as reference10_0_, purchaseor0_.status as status10_0_, purchaseor0_.updated as updated10_0_, purchaseor0_.user_id as user24_10_0_, purchaseor0_.views as views10_0_'
| \-[SQL_TOKEN] SqlFragment: 'shoppingba1_.call_center as call2_9_1_, shoppingba1_.call_center_fee as call3_9_1_, shoppingba1_.cardCharge as cardCharge9_1_, shoppingba1_.created as created9_1_, shoppingba1_.currency as currency9_1_, shoppingba1_.deliveryCost as delivery6_9_1_, shoppingba1_.delivery_option as delivery14_9_1_, shoppingba1_.deliveryType as delivery7_9_1_, shoppingba1_.insurance as insurance9_1_, shoppingba1_.owner as owner9_1_, shoppingba1_.promotionCode_id as promoti15_9_1_, shoppingba1_.status as status9_1_, shoppingba1_.unique_id as unique11_9_1_, shoppingba1_.updated as updated9_1_'
+-[FROM] FromClause: 'from' FromClause{level=1, fromElementCounter=2, fromElements=2, fromElementByClassAlias=[o], fromElementByTableAlias=[purchaseor0_, shoppingba1_], fromElementsByPath=[o.basket], collectionJoinFromElementsByPath=[], impliedElements=[]}
| \-[FROM_FRAGMENT] FromElement: 'purchaseorders purchaseor0_' FromElement{explicit,not a collection join,not a fetch join,fetch non-lazy properties,classAlias=o,role=null,tableName=purchaseorders,tableAlias=purchaseor0_,origin=null,columns={,className=com.ng.ticketlogic.core.shop.PurchaseOrder}}
| \-[JOIN_FRAGMENT] FromElement: 'inner join shoppingbaskets shoppingba1_ on purchaseor0_.basket_id=shoppingba1_.id' FromElement{explicit,not a collection join,fetch join,fetch non-lazy properties,classAlias=null,role=null,tableName=shoppingbaskets,tableAlias=shoppingba1_,origin=purchaseorders purchaseor0_,columns={purchaseor0_.basket_id ,className=com.ng.ticketlogic.core.shop.ShoppingBasket}}
+-[WHERE] SqlNode: 'where'
| \-[IN] InLogicOperatorNode: 'in'
| +-[DOT] DotNode: 'purchaseor0_.status' {propertyName=statusE,dereferenceType=ALL,propertyPath=statusE,path=o.statusE,tableAlias=purchaseor0_,className=com.ng.ticketlogic.core.shop.PurchaseOrder,classAlias=o}
| | +-[ALIAS_REF] IdentNode: 'purchaseor0_.id' {alias=o, className=com.ng.ticketlogic.core.shop.PurchaseOrder, tableAlias=purchaseor0_}
| | \-[IDENT] IdentNode: 'statusE' {originalText=statusE}
| \-[IN_LIST] SqlNode: 'inList'
| \-[NAMED_PARAM] ParameterNode: '?' {name=statuses, expectedType=org.hibernate.type.CustomType@493744b6}
\-[ORDER] OrderByClause: 'ORDER'
+-[DOT] DotNode: 'purchaseor0_.created' {propertyName=created,dereferenceType=ALL,propertyPath=created,path=o.created,tableAlias=purchaseor0_,className=com.ng.ticketlogic.core.shop.PurchaseOrder,classAlias=o}
| +-[ALIAS_REF] IdentNode: 'purchaseor0_.id' {alias=o, className=com.ng.ticketlogic.core.shop.PurchaseOrder, tableAlias=purchaseor0_}
| \-[IDENT] IdentNode: 'created' {originalText=created}
\-[DESCENDING] SqlNode: 'DESC'
DEBUG ErrorCounter - throwQueryException() : no errors
DEBUG QueryTranslatorImpl - HQL: from com.ng.ticketlogic.core.shop.PurchaseOrder o join fetch o.basket where o.statusE in (:statuses) ORDER BY o.created DESC
DEBUG QueryTranslatorImpl - SQL: select purchaseor0_.id as id10_0_, shoppingba1_.id as id9_1_, purchaseor0_.address_id as address17_10_0_, purchaseor0_.affiliate_id as affiliate18_10_0_, purchaseor0_.agreed_cardholder as agreed2_10_0_, purchaseor0_.agreed_terms as agreed3_10_0_, purchaseor0_.alternativeCustomerName as alternat4_10_0_, purchaseor0_.approved as approved10_0_, purchaseor0_.author as author10_0_, purchaseor0_.basket_id as basket19_10_0_, purchaseor0_.card_id as card20_10_0_, purchaseor0_.created as created10_0_, purchaseor0_.editor as editor10_0_, purchaseor0_.groupBookingId as groupBo21_10_0_, purchaseor0_.ip_address as ip9_10_0_, purchaseor0_.linkedOrder as linkedO22_10_0_, purchaseor0_.manual_hold as manual10_10_0_, purchaseor0_.manual_review as manual11_10_0_, purchaseor0_.partner_id as partner23_10_0_, purchaseor0_.platformType as platfor12_10_0_, purchaseor0_.reference as reference10_0_, purchaseor0_.status as status10_0_, purchaseor0_.updated as updated10_0_, purchaseor0_.user_id as user24_10_0_, purchaseor0_.views as views10_0_, shoppingba1_.call_center as call2_9_1_, shoppingba1_.call_center_fee as call3_9_1_, shoppingba1_.cardCharge as cardCharge9_1_, shoppingba1_.created as created9_1_, shoppingba1_.currency as currency9_1_, shoppingba1_.deliveryCost as delivery6_9_1_, shoppingba1_.delivery_option as delivery14_9_1_, shoppingba1_.deliveryType as delivery7_9_1_, shoppingba1_.insurance as insurance9_1_, shoppingba1_.owner as owner9_1_, shoppingba1_.promotionCode_id as promoti15_9_1_, shoppingba1_.status as status9_1_, shoppingba1_.unique_id as unique11_9_1_, shoppingba1_.updated as updated9_1_ from purchaseorders purchaseor0_ inner join shoppingbaskets shoppingba1_ on purchaseor0_.basket_id=shoppingba1_.id where purchaseor0_.status in (?) order by purchaseor0_.created DESC
DEBUG ErrorCounter - throwQueryException() : no errors
DEBUG QueryTranslatorImpl - parse() - HQL: from com.ng.ticketlogic.core.shop.PurchaseOrder o join fetch o.basket where o.statusE in (:statuses0_, :statuses1_, :statuses2_) ORDER BY o.created DESC
DEBUG AST - --- HQL AST ---
\-[QUERY] Node: 'query'
+-[SELECT_FROM] Node: 'SELECT_FROM'
| \-[FROM] Node: 'from'
| +-[RANGE] Node: 'RANGE'
| | +-[DOT] Node: '.'
| | | +-[DOT] Node: '.'
| | | | +-[DOT] Node: '.'
| | | | | +-[DOT] Node: '.'
| | | | | | +-[DOT] Node: '.'
| | | | | | | +-[IDENT] Node: 'com'
| | | | | | | \-[IDENT] Node: 'ng'
| | | | | | \-[IDENT] Node: 'ticketlogic'
| | | | | \-[IDENT] Node: 'core'
| | | | \-[IDENT] Node: 'shop'
| | | \-[IDENT] Node: 'PurchaseOrder'
| | \-[ALIAS] Node: 'o'
| \-[JOIN] Node: 'join'
| +-[FETCH] Node: 'fetch'
| \-[DOT] Node: '.'
| +-[IDENT] Node: 'o'
| \-[IDENT] Node: 'basket'
+-[WHERE] Node: 'where'
| \-[IN] Node: 'in'
| +-[DOT] Node: '.'
| | +-[IDENT] Node: 'o'
| | \-[IDENT] Node: 'statusE'
| \-[IN_LIST] Node: 'inList'
| +-[COLON] Node: ':'
| | \-[IDENT] Node: 'statuses0_'
| +-[COLON] Node: ':'
| | \-[IDENT] Node: 'statuses1_'
| \-[COLON] Node: ':'
| \-[IDENT] Node: 'statuses2_'
\-[ORDER] Node: 'ORDER'
+-[DOT] Node: '.'
| +-[IDENT] Node: 'o'
| \-[IDENT] Node: 'created'
\-[DESCENDING] Node: 'DESC'
DEBUG ErrorCounter - throwQueryException() : no errors
DEBUG HqlSqlBaseWalker - select << begin [level=1, statement=select]
DEBUG FromElement - FromClause{level=1} : com.ng.ticketlogic.core.shop.PurchaseOrder (o) -> purchaseor0_
DEBUG FromReferenceNode - Resolved : o -> purchaseor0_.id
DEBUG DotNode - getDataType() : basket -> org.hibernate.type.ManyToOneType(com.ng.ticketlogic.core.shop.ShoppingBasket)
DEBUG DotNode - dereferenceEntityJoin() : generating join for basket in com.ng.ticketlogic.core.shop.PurchaseOrder {no alias} parent = [ {null} ]
DEBUG FromElement - FromClause{level=1} : com.ng.ticketlogic.core.shop.ShoppingBasket (no alias) -> shoppingba1_
DEBUG FromClause - addJoinByPathMap() : o.basket -> FromElement{explicit,not a collection join,not a fetch join,fetch non-lazy properties,classAlias=null,role=null,tableName=shoppingbaskets,tableAlias=shoppingba1_,origin=purchaseorders purchaseor0_,columns={purchaseor0_.basket_id ,className=com.ng.ticketlogic.core.shop.ShoppingBasket}}
DEBUG FromReferenceNode - Resolved : o.basket -> purchaseor0_.basket_id
DEBUG HqlSqlWalker - createFromJoinElement() : -- join tree --
\-[JOIN_FRAGMENT] FromElement: 'shoppingbaskets shoppingba1_' FromElement{explicit,not a collection join,fetch join,fetch non-lazy properties,classAlias=null,role=null,tableName=shoppingbaskets,tableAlias=shoppingba1_,origin=purchaseorders purchaseor0_,columns={purchaseor0_.basket_id ,className=com.ng.ticketlogic.core.shop.ShoppingBasket}}
DEBUG FromReferenceNode - Resolved : o -> purchaseor0_.id
DEBUG DotNode - getDataType() : statusE -> org.hibernate.type.CustomType@493744b6
DEBUG FromReferenceNode - Resolved : o.statusE -> purchaseor0_.status
DEBUG FromReferenceNode - Resolved : o -> purchaseor0_.id
DEBUG DotNode - getDataType() : created -> org.hibernate.type.TimestampType@69a4e343
DEBUG FromReferenceNode - Resolved : o.created -> purchaseor0_.created
DEBUG HqlSqlBaseWalker - select : finishing up [level=1, statement=select]
DEBUG HqlSqlWalker - processQuery() : ( SELECT ( FromClause{level=1} ( purchaseorders purchaseor0_ shoppingbaskets shoppingba1_ ) ) ( where ( in ( purchaseor0_.status purchaseor0_.id statusE ) ( inList ? ? ? ) ) ) ( ORDER ( purchaseor0_.created purchaseor0_.id created ) DESC ) )
DEBUG HqlSqlWalker - Derived SELECT clause created.
DEBUG JoinProcessor - Using FROM fragment [purchaseorders purchaseor0_]
DEBUG JoinProcessor - Using FROM fragment [inner join shoppingbaskets shoppingba1_ on purchaseor0_.basket_id=shoppingba1_.id]
DEBUG HqlSqlBaseWalker - select >> end [level=1, statement=select]
DEBUG AST - --- SQL AST ---
\-[SELECT] QueryNode: 'SELECT' querySpaces (purchaseorders,shoppingbaskets)
+-[SELECT_CLAUSE] SelectClause: '{derived select clause}'
| +-[SELECT_EXPR] SelectExpressionImpl: 'purchaseor0_.id as id10_0_' {FromElement{explicit,not a collection join,not a fetch join,fetch non-lazy properties,classAlias=o,role=null,tableName=purchaseorders,tableAlias=purchaseor0_,origin=null,columns={,className=com.ng.ticketlogic.core.shop.PurchaseOrder}}}
| +-[SELECT_EXPR] SelectExpressionImpl: 'shoppingba1_.id as id9_1_' {FromElement{explicit,not a collection join,fetch join,fetch non-lazy properties,classAlias=null,role=null,tableName=shoppingbaskets,tableAlias=shoppingba1_,origin=purchaseorders purchaseor0_,columns={purchaseor0_.basket_id ,className=com.ng.ticketlogic.core.shop.ShoppingBasket}}}
| +-[SQL_TOKEN] SqlFragment: 'purchaseor0_.address_id as address17_10_0_, purchaseor0_.affiliate_id as affiliate18_10_0_, purchaseor0_.agreed_cardholder as agreed2_10_0_, purchaseor0_.agreed_terms as agreed3_10_0_, purchaseor0_.alternativeCustomerName as alternat4_10_0_, purchaseor0_.approved as approved10_0_, purchaseor0_.author as author10_0_, purchaseor0_.basket_id as basket19_10_0_, purchaseor0_.card_id as card20_10_0_, purchaseor0_.created as created10_0_, purchaseor0_.editor as editor10_0_, purchaseor0_.groupBookingId as groupBo21_10_0_, purchaseor0_.ip_address as ip9_10_0_, purchaseor0_.linkedOrder as linkedO22_10_0_, purchaseor0_.manual_hold as manual10_10_0_, purchaseor0_.manual_review as manual11_10_0_, purchaseor0_.partner_id as partner23_10_0_, purchaseor0_.platformType as platfor12_10_0_, purchaseor0_.reference as reference10_0_, purchaseor0_.status as status10_0_, purchaseor0_.updated as updated10_0_, purchaseor0_.user_id as user24_10_0_, purchaseor0_.views as views10_0_'
| \-[SQL_TOKEN] SqlFragment: 'shoppingba1_.call_center as call2_9_1_, shoppingba1_.call_center_fee as call3_9_1_, shoppingba1_.cardCharge as cardCharge9_1_, shoppingba1_.created as created9_1_, shoppingba1_.currency as currency9_1_, shoppingba1_.deliveryCost as delivery6_9_1_, shoppingba1_.delivery_option as delivery14_9_1_, shoppingba1_.deliveryType as delivery7_9_1_, shoppingba1_.insurance as insurance9_1_, shoppingba1_.owner as owner9_1_, shoppingba1_.promotionCode_id as promoti15_9_1_, shoppingba1_.status as status9_1_, shoppingba1_.unique_id as unique11_9_1_, shoppingba1_.updated as updated9_1_'
+-[FROM] FromClause: 'from' FromClause{level=1, fromElementCounter=2, fromElements=2, fromElementByClassAlias=[o], fromElementByTableAlias=[purchaseor0_, shoppingba1_], fromElementsByPath=[o.basket], collectionJoinFromElementsByPath=[], impliedElements=[]}
| \-[FROM_FRAGMENT] FromElement: 'purchaseorders purchaseor0_' FromElement{explicit,not a collection join,not a fetch join,fetch non-lazy properties,classAlias=o,role=null,tableName=purchaseorders,tableAlias=purchaseor0_,origin=null,columns={,className=com.ng.ticketlogic.core.shop.PurchaseOrder}}
| \-[JOIN_FRAGMENT] FromElement: 'inner join shoppingbaskets shoppingba1_ on purchaseor0_.basket_id=shoppingba1_.id' FromElement{explicit,not a collection join,fetch join,fetch non-lazy properties,classAlias=null,role=null,tableName=shoppingbaskets,tableAlias=shoppingba1_,origin=purchaseorders purchaseor0_,columns={purchaseor0_.basket_id ,className=com.ng.ticketlogic.core.shop.ShoppingBasket}}
+-[WHERE] SqlNode: 'where'
| \-[IN] InLogicOperatorNode: 'in'
| +-[DOT] DotNode: 'purchaseor0_.status' {propertyName=statusE,dereferenceType=ALL,propertyPath=statusE,path=o.statusE,tableAlias=purchaseor0_,className=com.ng.ticketlogic.core.shop.PurchaseOrder,classAlias=o}
| | +-[ALIAS_REF] IdentNode: 'purchaseor0_.id' {alias=o, className=com.ng.ticketlogic.core.shop.PurchaseOrder, tableAlias=purchaseor0_}
| | \-[IDENT] IdentNode: 'statusE' {originalText=statusE}
| \-[IN_LIST] SqlNode: 'inList'
| +-[NAMED_PARAM] ParameterNode: '?' {name=statuses0_, expectedType=org.hibernate.type.CustomType@493744b6}
| +-[NAMED_PARAM] ParameterNode: '?' {name=statuses1_, expectedType=org.hibernate.type.CustomType@493744b6}
| \-[NAMED_PARAM] ParameterNode: '?' {name=statuses2_, expectedType=org.hibernate.type.CustomType@493744b6}
\-[ORDER] OrderByClause: 'ORDER'
+-[DOT] DotNode: 'purchaseor0_.created' {propertyName=created,dereferenceType=ALL,propertyPath=created,path=o.created,tableAlias=purchaseor0_,className=com.ng.ticketlogic.core.shop.PurchaseOrder,classAlias=o}
| +-[ALIAS_REF] IdentNode: 'purchaseor0_.id' {alias=o, className=com.ng.ticketlogic.core.shop.PurchaseOrder, tableAlias=purchaseor0_}
| \-[IDENT] IdentNode: 'created' {originalText=created}
\-[DESCENDING] SqlNode: 'DESC'
DEBUG ErrorCounter - throwQueryException() : no errors
DEBUG QueryTranslatorImpl - HQL: from com.ng.ticketlogic.core.shop.PurchaseOrder o join fetch o.basket where o.statusE in (:statuses0_, :statuses1_, :statuses2_) ORDER BY o.created DESC
DEBUG QueryTranslatorImpl - SQL: select purchaseor0_.id as id10_0_, shoppingba1_.id as id9_1_, purchaseor0_.address_id as address17_10_0_, purchaseor0_.affiliate_id as affiliate18_10_0_, purchaseor0_.agreed_cardholder as agreed2_10_0_, purchaseor0_.agreed_terms as agreed3_10_0_, purchaseor0_.alternativeCustomerName as alternat4_10_0_, purchaseor0_.approved as approved10_0_, purchaseor0_.author as author10_0_, purchaseor0_.basket_id as basket19_10_0_, purchaseor0_.card_id as card20_10_0_, purchaseor0_.created as created10_0_, purchaseor0_.editor as editor10_0_, purchaseor0_.groupBookingId as groupBo21_10_0_, purchaseor0_.ip_address as ip9_10_0_, purchaseor0_.linkedOrder as linkedO22_10_0_, purchaseor0_.manual_hold as manual10_10_0_, purchaseor0_.manual_review as manual11_10_0_, purchaseor0_.partner_id as partner23_10_0_, purchaseor0_.platformType as platfor12_10_0_, purchaseor0_.reference as reference10_0_, purchaseor0_.status as status10_0_, purchaseor0_.updated as updated10_0_, purchaseor0_.user_id as user24_10_0_, purchaseor0_.views as views10_0_, shoppingba1_.call_center as call2_9_1_, shoppingba1_.call_center_fee as call3_9_1_, shoppingba1_.cardCharge as cardCharge9_1_, shoppingba1_.created as created9_1_, shoppingba1_.currency as currency9_1_, shoppingba1_.deliveryCost as delivery6_9_1_, shoppingba1_.delivery_option as delivery14_9_1_, shoppingba1_.deliveryType as delivery7_9_1_, shoppingba1_.insurance as insurance9_1_, shoppingba1_.owner as owner9_1_, shoppingba1_.promotionCode_id as promoti15_9_1_, shoppingba1_.status as status9_1_, shoppingba1_.unique_id as unique11_9_1_, shoppingba1_.updated as updated9_1_ from purchaseorders purchaseor0_ inner join shoppingbaskets shoppingba1_ on purchaseor0_.basket_id=shoppingba1_.id where purchaseor0_.status in (? , ? , ?) order by purchaseor0_.created DESC
DEBUG ErrorCounter - throwQueryException() : no errors
DEBUG AbstractBatcher - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
DEBUG SQL - select purchaseor0_.id as id10_0_, shoppingba1_.id as id9_1_, purchaseor0_.address_id as address17_10_0_, purchaseor0_.affiliate_id as affiliate18_10_0_, purchaseor0_.agreed_cardholder as agreed2_10_0_, purchaseor0_.agreed_terms as agreed3_10_0_, purchaseor0_.alternativeCustomerName as alternat4_10_0_, purchaseor0_.approved as approved10_0_, purchaseor0_.author as author10_0_, purchaseor0_.basket_id as basket19_10_0_, purchaseor0_.card_id as card20_10_0_, purchaseor0_.created as created10_0_, purchaseor0_.editor as editor10_0_, purchaseor0_.groupBookingId as groupBo21_10_0_, purchaseor0_.ip_address as ip9_10_0_, purchaseor0_.linkedOrder as linkedO22_10_0_, purchaseor0_.manual_hold as manual10_10_0_, purchaseor0_.manual_review as manual11_10_0_, purchaseor0_.partner_id as partner23_10_0_, purchaseor0_.platformType as platfor12_10_0_, purchaseor0_.reference as reference10_0_, purchaseor0_.status as status10_0_, purchaseor0_.updated as updated10_0_, purchaseor0_.user_id as user24_10_0_, purchaseor0_.views as views10_0_, shoppingba1_.call_center as call2_9_1_, shoppingba1_.call_center_fee as call3_9_1_, shoppingba1_.cardCharge as cardCharge9_1_, shoppingba1_.created as created9_1_, shoppingba1_.currency as currency9_1_, shoppingba1_.deliveryCost as delivery6_9_1_, shoppingba1_.delivery_option as delivery14_9_1_, shoppingba1_.deliveryType as delivery7_9_1_, shoppingba1_.insurance as insurance9_1_, shoppingba1_.owner as owner9_1_, shoppingba1_.promotionCode_id as promoti15_9_1_, shoppingba1_.status as status9_1_, shoppingba1_.unique_id as unique11_9_1_, shoppingba1_.updated as updated9_1_ from purchaseorders purchaseor0_ inner join shoppingbaskets shoppingba1_ on purchaseor0_.basket_id=shoppingba1_.id where purchaseor0_.status in (? , ? , ?) order by purchaseor0_.created DESC limit ?
DEBUG AbstractBatcher - about to open ResultSet (open ResultSets: 0, globally: 0)
DEBUG Loader - result row: EntityKey[com.ng.ticketlogic.core.shop.PurchaseOrder#615430], EntityKey[com.ng.ticketlogic.core.shop.ShoppingBasket#1608284]
DEBUG Loader - result row: EntityKey[com.ng.ticketlogic.core.shop.PurchaseOrder#614920], EntityKey[com.ng.ticketlogic.core.shop.ShoppingBasket#1607774]
DEBUG Loader - result row: EntityKey[com.ng.ticketlogic.core.shop.PurchaseOrder#614875], EntityKey[com.ng.ticketlogic.core.shop.ShoppingBasket#1607729]
DEBUG Loader - result row: EntityKey[com.ng.ticketlogic.core.shop.PurchaseOrder#610567], EntityKey[com.ng.ticketlogic.core.shop.ShoppingBasket#1603430]
DEBUG Loader - result row: EntityKey[com.ng.ticketlogic.core.shop.PurchaseOrder#608160], EntityKey[com.ng.ticketlogic.core.shop.ShoppingBasket#1601039]
DEBUG Loader - result row: EntityKey[com.ng.ticketlogic.core.shop.PurchaseOrder#601660], EntityKey[com.ng.ticketlogic.core.shop.ShoppingBasket#1594566]
DEBUG AbstractBatcher - about to close ResultSet (open ResultSets: 1, globally: 1)
DEBUG AbstractBatcher - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
DEBUG TwoPhaseLoad - resolving associations for [com.ng.ticketlogic.core.shop.PurchaseOrder#615430]
DEBUG TwoPhaseLoad - done materializing entity [com.ng.ticketlogic.core.shop.PurchaseOrder#615430]
DEBUG TwoPhaseLoad - resolving associations for [com.ng.ticketlogic.core.shop.ShoppingBasket#1608284]
DEBUG Loader - loading entity: [com.ng.ticketlogic.core.shop.PurchaseOrder#1608284]
DEBUG AbstractBatcher - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
DEBUG SQL - select purchaseor0_.id as id10_0_, purchaseor0_.address_id as address17_10_0_, purchaseor0_.affiliate_id as affiliate18_10_0_, purchaseor0_.agreed_cardholder as agreed2_10_0_, purchaseor0_.agreed_terms as agreed3_10_0_, purchaseor0_.alternativeCustomerName as alternat4_10_0_, purchaseor0_.approved as approved10_0_, purchaseor0_.author as author10_0_, purchaseor0_.basket_id as basket19_10_0_, purchaseor0_.card_id as card20_10_0_, purchaseor0_.created as created10_0_, purchaseor0_.editor as editor10_0_, purchaseor0_.groupBookingId as groupBo21_10_0_, purchaseor0_.ip_address as ip9_10_0_, purchaseor0_.linkedOrder as linkedO22_10_0_, purchaseor0_.manual_hold as manual10_10_0_, purchaseor0_.manual_review as manual11_10_0_, purchaseor0_.partner_id as partner23_10_0_, purchaseor0_.platformType as platfor12_10_0_, purchaseor0_.reference as reference10_0_, purchaseor0_.status as status10_0_, purchaseor0_.updated as updated10_0_, purchaseor0_.user_id as user24_10_0_, purchaseor0_.views as views10_0_ from purchaseorders purchaseor0_ where purchaseor0_.basket_id=?
DEBUG AbstractBatcher - about to open ResultSet (open ResultSets: 0, globally: 0)
DEBUG Loader - result row: EntityKey[com.ng.ticketlogic.core.shop.PurchaseOrder#615430]
DEBUG AbstractBatcher - about to close ResultSet (open ResultSets: 1, globally: 1)
DEBUG AbstractBatcher - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
DEBUG Loader - done entity load
DEBUG TwoPhaseLoad - done materializing entity [com.ng.ticketlogic.core.shop.ShoppingBasket#1608284]
最佳答案
Using FetchMode.JOIN
disables LAZY loading.产生的行为可能不是您所期望的。试试这个:
@OneToOne(cascade=CascadeType.ALL, fetch = FetchType.LAZY, optional = false)
@JoinColumn(name="basket_id")
public ShoppingBasket getBasket() {
return this.basket;
}
@OneToOne(mappedBy = "basket", cascade=CascadeType.ALL, fetch = FetchType.LAZY, optional = false)
public PurchaseOrder getOrder() {
return order;
}
之后,您的查询将只执行单个数据库查询。结果将包含一个 PurchaseOrder 对象列表,每个对象都具有正确初始化的购物篮属性。
附带说明:双向、相互需要、一对一的关系真的是必需的吗?从业务的角度来看,采购订单是在购物篮的生命周期之后创建的,因此不需要对它的引用(它应该包含基于购物篮内容创建的订单项目列表)。但这只是一个建议。
关于hibernate - 关于 Jpa 和 Hibernate 双向一对一的 N+1 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19322668/
我看到以下宏 here . static const char LogTable256[256] = { #define LT(n) n, n, n, n, n, n, n, n, n, n, n,
这个问题不太可能帮助任何 future 的访问者;它只与一个小的地理区域、一个特定的时间点或一个非常狭窄的情况有关,这些情况并不普遍适用于互联网的全局受众。为了帮助使这个问题更广泛地适用,visit
所以我得到了这个算法我需要计算它的时间复杂度 这样的 for i=1 to n do k=i while (k<=n) do FLIP(A[k]) k
n 的 n 次方(即 n^n)是多项式吗? T(n) = 2T(n/2) + n^n 可以用master方法求解吗? 最佳答案 它不仅不是多项式,而且比阶乘还差。 O(n^n) 支配 O(n!)。同样
我正在研究一种算法,它可以在带有变音符号的字符(tilde、circumflex、caret、umlaut、caron)及其“简单”字符之间进行映射。 例如: ń ǹ ň ñ ṅ ņ ṇ
嗯..我从昨天开始学习APL。我正在观看 YouTube 视频,从基础开始学习各种符号,我正在使用 NARS2000。 我想要的是打印斐波那契数列。我知道有好几种代码,但是因为我没有研究过高深的东西,
已关闭。这个问题是 off-topic 。目前不接受答案。 想要改进这个问题吗? Update the question所以它是on-topic用于堆栈溢出。 已关闭12 年前。 Improve th
谁能帮我从 N * N * N → N 中找到一个双射数学函数,它接受三个参数 x、y 和 z 并返回数字 n? 我想知道函数 f 及其反函数 f',如果我有 n,我将能够通过应用 f'(n) 来
场景: 用户可以在字符串格式的方程式中输入任意数量的括号对。但是,我需要检查以确保所有括号 ( 或 ) 都有一个相邻的乘数符号 *。因此 3( 应该是 3*( 和 )3 应该是 )*3。 我需要将所有
在 Java 中,表达式: n+++n 似乎评估为等同于: n++ + n 尽管 +n 是一个有效的一元运算符,其优先级高于 n + n 中的算术 + 运算符。因此编译器似乎假设运算符不能是一元运算符
当我阅读 this 问题我记得有人曾经告诉我(很多年前),从汇编程序的角度来看,这两个操作非常不同: n = 0; n = n - n; 这是真的吗?如果是,为什么会这样? 编辑: 正如一些回复所指出
我正在尝试在reveal.js 中加载外部markdown 文件,该文件已编写为遵守数据分隔符语法: You can write your content as a separate file and
我试图弄清楚如何使用 Javascript 生成一个随机 11 个字符串,该字符串需要特定的字母/数字序列,以及位置。 ----------------------------------------
我最近偶然发现了一个资源,其中 2T(n/2) + n/log n 类型 的递归被 MM 宣布为无法解决。 直到今天,当另一种资源被证明是矛盾的(在某种意义上)时,我才接受它作为引理。 根据资源(下面
关闭。此题需要details or clarity 。目前不接受答案。 想要改进这个问题吗?通过 editing this post 添加详细信息并澄清问题. 已关闭 8 年前。 Improve th
我完成的一个代码遵循这个模式: for (i = 0; i < N; i++){ // O(N) //do some processing... } sort(array, array + N
有没有办法证明 f(n) + g(n) = theta(n^2) 还是不可能?假设 f(n) = theta(n^2) & g(n) = O(n^2) 我尝试了以下方法:f(n) = O(n^2) &
所以我目前正在尝试计算我拥有的一些数据的 Pearson R 和 p 值。这是通过以下代码完成的: import numpy as np from scipy.stats import pearson
ltree 列的默认排序为文本。示例:我的表 id、parentid 和 wbs 中有 3 列。 ltree 列 - wbs 将 1.1.12, 1.1.1, 1.1.2 存储在不同的行中。按 wbs
我的目标是编写一个程序来计算在 python 中表示数字所需的位数,如果我选择 number = -1 或任何负数,程序不会终止,这是我的代码: number = -1 cnt = 0 while(n
我是一名优秀的程序员,十分优秀!