Is the entity-beans rubbish?

Hi, all!

I'am a beginner EJB-developer. I'am seeking the place of using for the entity-beans. And I can't do it. The entity-bean's container encapsulates database level. "That's fine! If the business objects will be changed, I'll change several lines of my code only.", all say. I agree with it.

But...

Run a simple mental experiment.

Let the small or middle company has a trading system. This system includes several business objects, as follows: "The goods", "The customer", "The order". There are 46.000 goods, 350 customers and 2400 orders into the system. Each of them is a entity-bean...

Once day the chief will say to developer "Give me the report about customers, which: a)make their purchases during last year's may; b)the purchases from item (a) must contain the red caps; c)the average total cost of the last year's orders of the customers must be more than $1500... and so on". What is to be done? To make the complicated nesting loops? EJB QL's ability is not enough for this problem. But this problem is typically.

Databases (relation or OO) was developed especially for operation on the large data structures (remember indexing, table clustering and so on). I think, the using of entity-beans decreases the performance of the information system in many case, and gives very dubious advantage of DB encapsulating.

Am I wrong? ;0)

[1415 byte] By [gudkovanatoly] at [2007-9-27 1:22:13]
# 1
I am guessing your's is really an implementation / pattern question ?look at http://developer.java.sun.com/developer/technicalArticles/J2EE/patterns/
subir at 2007-7-4 19:09:23 > top of Java-index,Other Topics,Patterns & OO Design...
# 2

Entities are to be used only in a transactionnal context : chiefly inserts, updates & deletes.

Not for read only purposes, which have a high performance penalty against the container.

For such readouts, you need to look at the Value Object Assembler and Value List Handler patterns.

Furthermore, even in a transactionnal context each table doesn't need to be mapped as an Entity Bean. This is the wrong approach. -too fine-grained - one solution is to use arbitrary java objects in a synchronized vector, and only higher level entities of your model as EJB.

For such a complex insert/update please refer to the Aggregate / Composite Entity pattern.

jjjeep at 2007-7-4 19:09:23 > top of Java-index,Other Topics,Patterns & OO Design...
# 3
jjjeep,Where can I find the patterns you mentioned in your note ?
SoomarM at 2007-7-4 19:09:23 > top of Java-index,Other Topics,Patterns & OO Design...
# 4

Sorry for the delay.

Try this : http://developer.java.sun.com/developer/technicalArticles/J2EE/patterns/

There were also sessions at the last JavaOne, u might want to try this other link :

http://servlet.java.sun.com/javaone/sf2002/conf/sessions/20-all-regular.en.jsp

jjjeep at 2007-7-4 19:09:23 > top of Java-index,Other Topics,Patterns & OO Design...