This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes Entity bean performance Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Entity bean performance" Watch "Entity bean performance" New topic
Author

Entity bean performance

Steve Yu
Ranch Hand

Joined: Mar 26, 2003
Posts: 60
Still rookie type question --- Reading the entity bean chapter it seems each bean instance represents a row from one or several tables(joins). I have an application that will display a table format data to front end. Basically each row of the table is obtained from some business logic but essentially from some table joins, so you can say basically each row in the html table maps to one row in database table. Since my output table is huge (more than 2000 rows), does it mean the server will create more than 2000 entity beans for me ? If that's the case, will it cause memory problem or any other performance issue ? How is this issue taken care of by server ?
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8903

Since my output table is huge (more than 2000 rows), does it mean the server will create more than 2000 entity beans for me ? If that's the case, will it cause memory problem or any other performance issue ? How is this issue taken care of by server


Yes it will create 2000 instances which should be avoided. Since you are using the data for display purpose, I would suggest you to use a session bean to read the 2000 rows rather than using entity beans.


Groovy
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8903

You may be intrested to read this J2EE design pattern
http://java.sun.com/blueprints/corej2eepatterns/Patterns/ValueListHandler.html
Frank Sikuluzu
Ranch Hand

Joined: Dec 16, 2003
Posts: 116
Originally posted by Pradeep Bhat:


Yes it will create 2000 instances which should be avoided. Since you are using the data for display purpose, I would suggest you to use a session bean to read the 2000 rows rather than using entity beans.


Do you mean if I just "display" without "modifying", I should avoid entity bean ? And use entity bean only when I try to "update" or "modify" data ?
David Harkness
Ranch Hand

Joined: Aug 07, 2003
Posts: 1646
Originally posted by Frank Sikuluzu:
Do you mean if I just "display" without "modifying", I should avoid entity bean ? And use entity bean only when I try to "update" or "modify" data ?

Entity beans come with a fair amount of baggage in the form of overhead and complexity. Sometimes the payoff is worth the cost, but if you merely need to display some data from a few tables, writing a session bean that uses JDBC to retrieve the data will be far easier and perform better.

Also, Hibernate is a popular and robust replacement for entity beans. While the configuration mapping files can be difficult at first to grok, tools like XDoclet can ease the process considerably. XDoclet also makes EJBs bearable.
Karthik Guru
Ranch Hand

Joined: Mar 06, 2001
Posts: 1209
Originally posted by David Harkness:

tools like XDoclet can ease the process considerably. XDoclet also makes EJBs bearable.


David , do you have any links to articles/ tutorials to write custom XDoclet templates , subtasks etc (other than the documentation)?

I got the source code and the templates that ship with the tool did help. But an article along the lines of 'advanced XDoclet would be of great help.

Given the number of layers in our application and repetitive code that does delegation , i see lots of places where XDoclet could help.
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8903

Originally posted by karthik Guru:


David , do you have any links to articles/ tutorials to write custom XDoclet templates , subtasks etc (other than the documentation)?

I got the source code and the templates that ship with the tool did help. But an article along the lines of 'advanced XDoclet would be of great help.

Given the number of layers in our application and repetitive code that does delegation , i see lots of places where XDoclet could help.


This book talks about extending Xdoclet.
http://www.theserverside.com/articles/article.tss?l=XDocletInActionReview
David Harkness
Ranch Hand

Joined: Aug 07, 2003
Posts: 1646
Yes, the book review that Pradeep links to (XDoclet in Action) has a 35-page chapter that discusses creating custom templates, tags and tasks. I just skimmed it and it seems to be a good start to get you going.

The user mailing list is quite helpful, and there are enough people that most facets are well-covered (EJB, Hibernate, WebLogic, JBoss, Struts).
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Entity bean performance
 
Similar Threads
question about entity bean
memory usage with EntityBeans
2 tables
Entity beans and database views
SQL AntiPattern - A lot of Join