• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Usage of EJB - Need clarification

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do u mean to say that instead of bean what if i use a normal java function or use of some other bean...
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic