Hi,
> How bad an idea is putting JDBC code in each set() method, and leaving
ejbStore() blank?
> Does putting Session beans in front of things like ejbCreate and ejbStore
slow things down enough to make that technique a bad practice, even if it
will theoretically save coding time later?
Both of these questions can easily be resolved by one single answer: No!
The guy who designed your first round of beans is obviously very unfamiliar
with Transactions and how they can drastically improve the database access
of your EJBs!
First of all, if you have SQL updates in every single one of your sets, then
say within a client session you call 4 set methods of a single bean. You
will wind up with 4 UPDATE calls to the database. Even if these 4 set
methods are wrapped in a txn, you will still have 4 UPDATE calls, which will
just occur at the end of the txn. If you have your SQL update done in
ejbStore, and make these same 4 calls in a txn, your bean will make just ONE
UPDATE call at the end of the txn!
Second of all, having clients (whether they be a java app, JSP or Servlet)
access entity beans directly will give you massive granularity problems!
Your network traffic will be intolerable because a lot more handshaking will
go on (THIS will cause serious performance issues!) and your transaction
granularity will really suck because transactions are bound to each method
call (see above to why you need larger txn boundaries). And no, you do NOT
want to evoke UserTransactions from the client side, because this will cause
more problems than solutions!
So you see, these two issues you described (database/transaction management
and session bean facade model) are two fundamental services provided by EJB
servers that programmers need to be fully aware of AND take advantage of!
Gene
-----Original Message-----
From: A mailing list for Enterprise JavaBeans development
[mailto:[EMAIL PROTECTED]]On Behalf Of Adena Galinsky
Sent: Wednesday, August 23, 2000 7:32 AM
To: [EMAIL PROTECTED]
Subject: Where do I find design tips? And why design in X way?
Hi everyone,
I just got back from a BEA class on creating J2EE applications. The class
was great, but the one thing it didn't cover was design: not _how_ to do
things, but why and when to do things.
Can anyone recommend good sites or books of design tips and pointers?
So far I have
http://www.weblogic.com/docs/classdocs/API_ejbdesign.html
and the O'Reilly EJB book, chapter 9
and maybe (theserverside.com and javasuccess.com - I saw others suggesting
those in previous posts to this list)
Are there other big obvious important sources of info? (or even not so big
or obvious)
Also, I have a story and a related question:
The guy who designed our first round of Entity beans put JDBC code in every
set() method which calls a corresponding set-stored procedure in the
database. The ejbStore() method he left blank. His explanation for this was
that Oracle does everything faster and better (he's pretty db focused), and
that Store() wastes time and increases the likelihood that dirty data will
be put back in the database. In his vision, the JSP's check which values
from any given form the user has changed, and then only calls set() for
those values. He also has no session bean facade to the entity bean,
because he says that just wastes server time, and that any
development-time-gain we might get is far offset by the loss in server
speed.
Then I went to the BEA course, and everyone practically passed out at the
idea of doing separate db set() calls for each column value. They all said
we should do aggregate updates as frequently as possible (setData(),
followed by ejbStore()). They also said that JSPs should never call the
entity beans directly, but should always go through session beans. Also, I
heard a lot of arguments for CMP at the course, though since then I seem to
hear a lot of talk floating around to the effect that CMP is terribly slow.
My questions are:
How bad an idea is putting JDBC code in each set() method, and leaving
ejbStore() blank?
Does putting Session beans in front of things like ejbCreate and ejbStore
slow things down enough to make that technique a bad practice, even if it
will theoretically save coding time later?
Is CMP really slower than BMP, and if so, under what conditions and why?
Can we use CMP to do some work in a bean, but not other work, and if so,
how?
I realize this is a lot, so any help, even just an answer to one of my
questions, would be greatly appreciated.....
Thanks!
-Adena Galinskyx
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".