gpt4 book ai didi

java - 何时在 Websphere Commerce 中使用访问 bean 或数据 bean?

转载 作者:行者123 更新时间:2023-11-30 04:36:31 27 4
gpt4 key购买 nike

什么时候适合在 Websphere 中使用数据 Bean 或访问 Bean?如果我问的是基本问题,请抱歉,我是 Websphere 的新手。

就我而言,我正在尝试按产品查找目录列表。最初我一直使用访问bean。这可行,但有时会返回非常大的结果集/似乎非常占用内存。

CatalogEntryDescriptionAccessBean cedabp = new CatalogEntryDescriptionAccessBean();
Enumeration cde = cedabp.findByCatalogEntry(productCatIdLong);

数据bean提供了相同的方法:

CatalogEntryDescriptionDataBean cedabp = new CatalogEntryDescriptionDataBean();
Enumeration cde = cedabp.findByCatalogEntry(productCatIdLong);

为什么我要使用一种 bean 而不是另一种?哪种更适合读取或写入数据?其中一个提供的数据是否已缓存/比另一个更新?

更新:

我发现这两个类有如下关系:

CatalogEntryDescriptionAccessBean
|_ CachedCatalogEntryDescriptionAccessBean
|_ CompactCatalogEntryDescriptionAccessBean
|_ CatalogEntryDescriptionDataBeanBase
|_ CatalogEntryDescriptionDataBean

因此,Data Bean 继承自 Access Bean,因此它包含相同的可见方法。

有趣的是,IBM 的文档指出:

Access beans provide ... caching of the home object, and reduced call traffic to the enterprise bean. Using access beans has additional advantages:

At run time the access bean caches the enterprise bean home object because look ups to the home object are expensive, in terms of time and resource usage. The access bean implements a copyHelper object that reduces the number of calls to the enterprise bean when commands get and set enterprise bean attributes. Only a single call to the enterprise bean is required when reading or writing multiple enterprise bean attributes.

目前,我很困惑如果访问 Bean 使用 CMP 来减少对实体 Bean 的调用,那么数据 Bean 的用途是什么?

我发现了更多文档,其中指出:

A data bean is a Java bean that is used in JSP pages to retrieve information from the enterprise bean. A simple data bean extends its corresponding access bean and implements the SmartDataBean interface. By extending an access bean, the data bean provides a simple representation (indirectly) of an entity bean: it encapsulates the properties that can be retrieved from or set within the entity bean.

最佳答案

DataBean 比 AccessBean 实现更多的缓存,因此可能减少对数据库的调用。

DataBean 适合在构成站点/Web 应用程序的 JSP 页面中使用,因为实例数量可能较低,并且它应该有助于控制访问数据库的事务数量。

AccessBean 的内存密集程度要低得多,因此更适合循环进程等。

您通常希望找到后端 WebSphere 命令和报告等中使用的 AccessBean。

关于java - 何时在 Websphere Commerce 中使用访问 bean 或数据 bean?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13397752/

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