我们使用OPENJPA与Tomcat一起使用由Elatic Path Software编写的旧版专有包org.apache.renamed.openjpa。我们发现将QuerySQLCache关闭是运行某些查询所必需的。例如,以下非常复杂的查询:
SELECT 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.DISPLAY_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 来自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 LEFT OUTER JOIN TLOCALIZEDPROPERTIES t5 ON t0。 UIDPK = t5.OBJECT_UID和? = t5.TYPE LEFT OUTER JOIN TCATALOG t4 ON t3.CATALOG_UID = t4.UIDPK 在哪里t0.UIDPK =?
导致错误:
org.apache.renamed.openjpa.persistence.PersistenceException: No value specified for parameter 2
缓存关闭时不会发生错误。请注意,此查询的来源是以特定于OPENJPA的方式编写的复杂获取关系。
它从查找包含Fetch组和货件的订单(接口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 Cache问题:
catalina.07080951.out:DEBUG 缓存未命中,同时查找键&#34; org.apache.renamed.openjpa.datacache.QueryKey@9202a145 [查询:[SELECT sr FROM ShippingRegionImpl sr ORDER BY sr.name],访问路径:[com.elasticpath.domain.shipping.impl.ShippingRegionImpl],subs:true,ignoreChanges:false,startRange:0,endRange:9223372036854775807,timeout:1800000]&#34;。 catalina.07080951.out:DEBUG Put key&#34; org.apache.renamed.openjpa.datacache.QueryKey@9202a145 [query:[SELECT sr FROM ShippingRegionImpl sr ORDER BY sr.name],访问路径:[com.elasticpath。 domain.shipping.impl.ShippingRegionImpl],潜艇:真,ignoreChanges:假,startRange:0,endRange:9223372036854775807,超时:1800000]&#34;进入缓存。
有没有办法修复我们的应用程序,允许我们在OpenJPA中启用QuerySQLCache? 很抱歉没有完全清楚的代码示例,整个代码将占用大量空间。提示很受欢迎。
答案 0 :(得分:1)
有没有办法修复我们的应用程序,允许我们在OpenJPA中打开QuerySQLCache?
简短回答,很可能不是。 QuerySQLCache中已经出现了许多已修复的错误。由于您使用的是重新打包的OpenJPA版本,我不认为您可以尝试更新版本的OpenJPA来查看您遇到的问题是否已修复?如果这样可以解决您的问题,则需要使用Elastic Path来更新它们发布的OpenJPA版本。