I am a bignner for J2EE.I want to know when I can omit Entitybeans for performance problems and directly access DB from sessionbeans?
There is no concrete rule for when Entity Beans are appropriate. Whether or not using them will improve performance depends on the way you develop your EBs, the way your app server supports them, and the way the EB clients access them (i.e, how many remote calls are made).
I think for any reasonable answer to this question you should read an EJB tutorial.
Note that EJB2.0 greatly improves the performance level of some EBs. Watch out of EJB2.0 books, some are coming out.
General Rule is ...
If you want to only read data from DB, then you could directly call SQL from you session Bean.
You must go thru Entity Bean if you manipulate the data to DB. It means both read and write or write.
I use entity beans only under the following scenario
- Data is read only or read mostly
and / or
- The bean models coarse grained complex business object spanning multiple tables in the database
I also use all the optimizations provided by the App Server vendor to reduce database access