This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes EJB and other Java EE Technologies and the fly likes Usage of EJB - Need clarification Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Usage of EJB - Need clarification" Watch "Usage of EJB - Need clarification" New topic
Author

Usage of EJB - Need clarification

arnav prateek
Greenhorn

Joined: Apr 06, 2006
Posts: 17
Hi,

I am new to EJB and I have small doubt abot it;s usage, Requesting to clarify it:

- Normally in projects, people are using stateless session bean to access database(for select, update and delete) and they leave data concurrency handling at database levels.
Now,(a) I am unable to understand what kind of benefit they are getting by useing stateless session bean?
(b) Instead of using Stateless Session bean If I will use simple java class then which kind of problems I may get into?

Hope you understand my questions? Looking for clarification...

Thanks in advance.
Maheswari Palanisamy
Greenhorn

Joined: Jun 07, 2006
Posts: 3
Do u mean to say that instead of bean what if i use a normal java function or use of some other bean...


Maheswari
Ali Aman
Greenhorn

Joined: Jun 05, 2006
Posts: 7
Basically Entity Beans are used to connect to the Database (it is not a good practice to connect to a database thru a Statless or Stateful Session bean) thru a JNDI Name.... JNDI Naming makes it easier to connect in an enterprise becuase it abstracts the datasource classname etc from the developer,

The main advantage of using EJBs over Simple beans is that J2EE has a moto of develop once deploy many, if there is a slight change in business logic etc, the developer can change the business requirements and redeploy the bean and the client wouldnt have a whiff about it.

Other than that there are many features in EJBs, for example the Container Managed Persistance in Entity Beans enable you to find, create, delete, update records in your database without going thru the hinderance of writing SQL Scripts which increases database integrity, another feature of Entity Beans is Container Managed Relationships which maintains schema integrity....

These are just some benefits that I guess are benefitial in a large environment over legacy systems when we compare EJBs and normal Java classes.
prasad kulkarni
Ranch Hand

Joined: Mar 19, 2006
Posts: 66
Ok I understood where you are struggling. Your mind is not ready to acccept that if a transaction is done by a simple java class , then why to write the ejb & all stuff........?
See when you write a simple class, the writer is resposible for taking care of
the DataBase commit/rollback, checking the rights of user , (authorization & authetication) and many more. All in one developer gets stucked to lot of other common functions as Transaction, Security etc other than core business logic. To remove this disadvantage EJB's are introduced. EJB's asks you to care only about business logic & dont care about all other stuff.
At start this will give you a boring feel.....but when your project becomes more complex, you want to get free from all other stuff as commit...rollback etc. Remember: decision to go with EJB or not is througly depends on need of project. If you want to develop a simple "Hello world" web site , in such condition obviously you need not to go with EJB.


scjp, scwcd
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Usage of EJB - Need clarification