gpt4 book ai didi

java - 如何修复 OpenJPA 查询 SQL CACHE 错误?

转载 作者:太空宇宙 更新时间:2023-11-04 06:39:34 24 4
gpt4 key购买 nike

我们将 OPENJPA 与 Tomcat 结合使用,并使用由 Elatic Path Software 准备的旧版专有包 org.apache.renamed.openjpa 进行操作。我们发现运行某些查询时需要关闭 QuerySQLCache。例如,以下相当复杂的查询:

选择 t0.CARRIER、t0.CODE、t0.DEFAULT_COST、t0.ENABLED、t0.GUID、t0.LAST_MODIFIED_DATE、t1.UIDPK、t1.TYPE、t2.UIDPK、t2.GUID、t2.NAME、t2.REGION_STR、t3.UIDPK、t4.UIDPK、 t4.CATALOG_CODE、t4.DEFAULT_LOCALE、t4.MASTER、t4.NAME、t3.STORECODE、t3.CONTENT_ENCODING、t3.COUNTRY、t3.CREDIT_CARD_CVV2_ENABLED、t3.DEFAULT_CURRENCY、t3.DEFAULT_LOCALE、t3.DESCRIPTION、t3.DIS PLAY_OUT_OF_STOCK、t3.EMAIL_SENDER_ADDRESS、t3.EMAIL_SENDER_NAME、t3.ENABLED、t3.NAME、t3.STORE_ADMIN_EMAIL、t3.STORE_FULL_CREDIT_CARDS、t3.STORE_STATE、t3.STORE_TYPE、t3.SUB_COUNTRY、t3.TIMEZONE、t3.URL 、 t5.OBJECT_UID、t5.UIDPK、t5.TYPE、t5.LOCALIZED_PROPERTY_KEY、t5.VALUE FROM TSHIPPINGSERVICELEVEL t0 LEFT OUTER JOIN TSHIPPINGCOSTCALCULATIONMETHOD t1 ON t0.SCCM_UID = t1.UIDPK LEFT OUTER JOIN TSHIPPINGREGION t2 ON t0.SHIPPING_REGION_UID = t2.UIDPK LEFT OUTER JOIN TSTORE t3 ON t0.STORE_ UID = t3.UIDPK 左外连接 TLOCALIZEDPROPERTIES t5 ON t0.UIDPK = t5.OBJECT_UID AND ? = t5.类型左外连接 TCATALOG t4 ON t3.CATALOG_UID = t4.UIDPK t0.UIDPK = 哪里?

导致错误:

org.apache.renamed.openjpa.persistence.PersistenceException: No value specified for parameter 2 

当缓存关闭时,不会发生此错误。请注意,此查询的起源来自以 OPENJPA 特定方式编写的复杂获取关系。
它从查找包含 Fetch 组和发货的订单(接口(interface) ShipOrder)开始。从 ShipOrder (PhysicalOrderShipmentImpl ) 的实现中,我们获取shippingServiceLevelInternal,它会生成 TSHIPPINGSERVICELEVEL 的 select 语句(请参阅下面的一些代码)。

@FetchGroup(name = FetchGroupConstants.ORDER_SEARCH, attributes = { 
@FetchAttribute(name = "orderNumber"),
@FetchAttribute(name = "shipments"),
...
@DataCache(enabled = false)
public class OrderImpl extends AbstractListenableEntityImpl
private List<OrderShipment> shipments = new ArrayList<OrderShipment>();


public interface PhysicalOrderShipment extends OrderShipment
...
ShippingServiceLevel getShippingServiceLevel();

@FetchGroup(name = FetchGroupConstants.ORDER_DEFAULT, attributes = {
@FetchAttribute(name = "shipmentAddressInternal"),
@FetchAttribute(name = "shippingServiceLevelInternal")
}, fetchGroups = { FetchGroupConstants.DEFAULT }, postLoad = true)
})
@DataCache(enabled = false)
public class PhysicalOrderShipmentImpl extends AbstractOrderShipmentImpl implements PhysicalOrderShipment {
...
/**
* Gets the shipping service level.
*
* @return ShippingServiceLevel the shipping service level
*/
ShippingServiceLevel getShippingServiceLevel();

从日志中我还看到一些 QuerySQL 缓存问题:

catalina.07080951.out:DEBUG 缓存未命中,同时查找键“org.apache.renamed.openjpa.datacache.QueryKey@9202a145[query:[SELECT sr FROM ShippingRegionImpl sr ORDER BY sr.name],访问路径:[com.elasticpath.domain.shipping.impl.ShippingRegionImpl],subs:true,ignoreChange s:假,开始范围:0,结束范围:9223372036854775807,超时:1800000]”。catalina.07080951.out:DEBUG Put key "org.apache.renamed.openjpa.datacache.QueryKey@9202a145[query:[SELECT sr FROM ShippingRegionImpl sr ORDER BY sr.name],访问路径:[com.elasticpath.domain.shipping.impl.ShippingRegionImpl],subs:true,ignoreChanges:false,startRange:0,endR ange:9223372036854775807,timeout:1800000]”进入缓存。

有什么方法可以修复我们的应用程序,使我们能够在 OpenJPA 中打开 QuerySQLCache?抱歉,代码示例不完全清晰,整个代码将占用大量空间。感谢提示。

最佳答案

Is there any way to fix our application allowing us to turn on QuerySQLCache in OpenJPA?

简短的回答,很可能不会。 QuerySQLCache 中的许多错误已得到修复。由于您使用的是重新打包版本的 OpenJPA,我认为您不可能尝试更新版本的 OpenJPA 来查看您遇到的问题是否已得到解决?如果这解决了您的问题,您将需要使用 Elastic Path 来更新他们提供的 OpenJPA 版本。

关于java - 如何修复 OpenJPA 查询 SQL CACHE 错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24870181/

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