Entity Bean finder methods VS DAO?

一世执手 提交于 2019-12-24 21:42:22

问题


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.


回答1:


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).

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.

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.



来源:https://stackoverflow.com/questions/2160462/entity-bean-finder-methods-vs-dao

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!