wood burning stoves 2.0*
The moose likes Architect Certification (SCEA/OCMJEA) and the fly likes Read only Entity beans? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Certification » Architect Certification (SCEA/OCMJEA)
Bookmark "Read only Entity beans?" Watch "Read only Entity beans?" New topic
Author

Read only Entity beans?

Parag Doshi
Ranch Hand

Joined: Jun 29, 2004
Posts: 317
Would you need entity beans if the information is only read only? In other words, if there are no transactional requirements for certain business objects, would you need to model them as entity beans? Or is there any other criterias which might influence the usage of entity beans for such read only business objects?

Any insight would be helpful..

Thanks,
Parag
[ August 18, 2004: Message edited by: Parag Doshi ]
Tomi Tuomainen
Ranch Hand

Joined: Jun 13, 2004
Posts: 86
I'm thinking to use DAO with query statements for read only data. As I "modeled" the database (in my head), I figured out that searching data with complex criteria would be quite tricky with entity beans. So I'm thinking to use entity beans only for data that needs to be inserted/updated. Though I'm not sure, if I'm following any "official" best practise...

Tomi
[ August 18, 2004: Message edited by: Tomi Tuomainen ]
Parag Doshi
Ranch Hand

Joined: Jun 29, 2004
Posts: 317
Originally posted by Tomi Tuomainen:
I'm thinking to use DAO with query statements for read only data. As I "modeled" the database (in my head), I figured out that searching data with complex criteria would be quite tricky with entity beans. So I'm thinking to use entity beans only for data that needs to be inserted/updated. Though I'm not sure, if I'm following any "official" best practise...

Tomi

[ August 18, 2004: Message edited by: Tomi Tuomainen ]


Yes Tomi, that makes sense to me too. I was looking at Value List Handler and Fast Lane Reader pattern and it occured that I may not need entity beans for my read only complex queries. Just wanted to make sure I was not missing anything

Parag
Roger Rustin
Greenhorn

Joined: Jul 08, 2004
Posts: 19
I am not using fast lane reader and understably I have to justify my decision in the assignment. Two reasons:

1)For read only data not using the enity beans is preferred primarily because entity beans are too heavyweight for such light operarion. More and more app servers are coming out with read-only entity beans ( I know of JBoss and weblogic). The app server does the optimization hence the entity beans are not so heavyweight.


2) If the swing applications want the same data and their is no entity beans then in a way there would be two implementations of fast lane reader - one for web and one for swing clients.


I belive that as architects we should leverage the best features available rather than going by the patterns just for the sake of using it and impressing the examiner. If you truly belive that fast lane reader is the best fit for your app the do go for it.

my two cents !!!
- Roger
Parag Doshi
Ranch Hand

Joined: Jun 29, 2004
Posts: 317
Originally posted by Roger Rustin:
I am not using fast lane reader and understably I have to justify my decision in the assignment. Two reasons:

1)For read only data not using the enity beans is preferred primarily because entity beans are too heavyweight for such light operarion. More and more app servers are coming out with read-only entity beans ( I know of JBoss and weblogic). The app server does the optimization hence the entity beans are not so heavyweight.


2) If the swing applications want the same data and their is no entity beans then in a way there would be two implementations of fast lane reader - one for web and one for swing clients.


I belive that as architects we should leverage the best features available rather than going by the patterns just for the sake of using it and impressing the examiner. If you truly belive that fast lane reader is the best fit for your app the do go for it.

my two cents !!!
- Roger


Roger,
I agree with your thoughts. Even I do not want to use entity beans just for the sake of it. But, I was under the impression that a fast lane reader does not use entity beans. It bypasses the entity beans and goes directly to the data store. A quote from the fast lane reader j2ee pattern site :


The Fast Lane Reader design pattern provides a more efficient way to access tabular, read-only data. A fast lane reader component directly accesses persistent data using JDBCTM components, instead of using entity beans. The result is improved performance and less coding, because the component represents data in a form that is closer to how the data are used.


This meets both my web app and my swing app requirements and it does not use entity beans. Yeah, I would have to go through a session facade or stateless session bean via the business delegate, but that seems alrite and is needed as per my understanding.

Am I missing something or did i misunderstand your comments? Are you talking about using entity beans instead of the fast lane reader?

Parag

[ August 18, 2004: Message edited by: Parag Doshi ]
[ August 18, 2004: Message edited by: Parag Doshi ]
Roger Rustin
Greenhorn

Joined: Jul 08, 2004
Posts: 19
Parag,

You are absolutely right. As I understand there are two ways of implementing fast lane reader.

1) Direct connection to database bypassing the appserver. Personally I don't like it since it leaves the app server out. Secondly tommorrow if a new type of client wants to avail the same service, the developer will have to code all the way until getting the data from the db.

2) get the data using stateless session bean (SLSB). Since it's SLSB and there is no entity bean the developer will write his/her own sql queries. My argument is why write the query when one could easily mention all this in a read only entity bean; in this way the code is much more maintainable. You can see from my line of reasoning that I don't have as much disdain for CMP as most of the people I have encountered.

Good luck!

- Roger
Roger Rustin
Greenhorn

Joined: Jul 08, 2004
Posts: 19
Forgot to add that I find testing sql queries by far most time consuming and buggy.
Parag Doshi
Ranch Hand

Joined: Jun 29, 2004
Posts: 317
Roger,
I dont think entity beans are "bad" and it has its importance and relevance in many implementations. As I had earlier posted, I wanted to know would entity beans be used if the data is only read only and I wanted to weigh the pros and cons of using entity beans in this scenario.

I was indicating the implementing of FastLaneReader via SLSB. I dont think that I would use entity beans just because my java developers dont know good sql. frankly, I would use the services of a DBA to help fine tune the sql and I know from personal experience that a DBA can use many tricks and optimization techniques to fine tune the queries based on the environment in which the application runs. EJB/QL might be good and a strong tool for declarative SQL queries, but I am not sure how effective it would be in creating complex sql queries having joins, sub queries, unions, database hints etc and also customizing the queries based on target database environment.

Again, what would you do if would have to use BMP due to some of your business requirements? Would you rule out BMP just because the java developers cant write effective SQL?

Coming back to my original problem of read only data, I would consider using EJB as it helps towards my scalability goals. Then again, I would weigh that against the performance comparison between the fast lane reader and entity beans.

I am still unsure whether FastLaneReader is the best solution over entity beans when it comes to read only data or vice versa.

Parag
Roger Rustin
Greenhorn

Joined: Jul 08, 2004
Posts: 19
Hi Parga,

Thanks for the strong pursuasive arguments. In the last line you mentioned you are still not sure. I think you answered your question yourself. As I read it if it's a complicated sql query and performance is a factor then go for BMP or else use CMP since you have already zeroed down to SLSB.


Thanks again.

- Roger
 
Don't get me started about those stupid light bulbs.
 
subject: Read only Entity beans?