实体Bean查找器方法VS DAO? [英] Entity Bean finder methods VS DAO?

查看:92
本文介绍了实体Bean查找器方法VS DAO?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我删除实体bean(查找器方法)并引入DAO层,将会提高性能。我主要是想从数据库中读取数据。我的项目中有一个流程,该流程中约有15个实体Bean查找器调用,因此,如果删除实体Bean或引入DAO并保留实体Bean,则性能会得到很大的改善吗?我正在使用EJB 2.1。

Will there be a performance improvement if I remove the entity bean (finder methods) and introduce the DAO layer instead. I want to do this mainly for reading data from the DB. I have a process in my project which has around 15 entity beans finder call in the flow, so if I remove the Entity beans or introduce a DAO and leave the entity beans as it is will there be a significant improvement in the performance ? I am using EJB 2.1.

推荐答案

使用Entity Bean查找器检索数据会加载实体的所有属性,即使您对于手头的任务可能只需要其中之一的值。因此,确实,EJB查找器方法有开销,并且在检索大型数据集时尤其如此(更不用说在调用其中的15个数据集时了)。

Retrieving data by using Entity Bean finders loads all of the attributes for the entity, even when you might only need the value of one of them for the task at hand. So, indeed, EJB finders methods have overhead and this is especially true when retrieving large data sets (not even to mention when you are invoking 15 of them).

因此,要检索大型只读数据集,直接从Session Bean与数据库进行通讯确实是更好的选择(猜测您拥有使用JDBC API的Session Bean外观。如果我没有记错的话,这种模式称为快速车道阅读器

So, to retrieve large read-only data sets, it may indeed be preferable to talk to the database directly from the Session Bean (I guess that you have a Session Bean facade) using JDBC API. This pattern is known as Fast Lane Reader if I remember well.

请记住,此模式的实现会牺牲数据一致性以提高性能,因为在原始JDBC级别执行的查询不会看到对表示的业务信息所做的未决更改通过Enterprise Beans。

Just keep in mind that implementations of this pattern sacrifice data consistency for performance, since queries performed at the raw JDBC level do not "see" pending changes made to business information represented by Enterprise Beans.

这篇关于实体Bean查找器方法VS DAO?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆