Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt in entity bean !! its urgent

 
manish basotia
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I have a doubt on enity bean. Just to explain i am giving an example.

In a J2ee project say i have some page which takes some input from a user, Then on submit i pass these inputs to a session bean which does some processing of the data and finally store it in database. Later i can display the processed information to the user.

??
now what i want to know is in such kind of scenario where does entity bean fit into picture, what i mean i can directly query some records and display it to the user.
??

Note :- I just taken an example to explain the condition, what i want to now is in high level project where at broad level , typically the scenario will be same so with respect to that please let me know where exactly do we use entity bean, and how it is beneficial.

Thanks
 
Greg Charles
Sheriff
Posts: 2985
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, typically an entity bean would be used for the "CRUD" operations: Create, Retrieve, Update, Delete. An entity bean represents one row of data from a database table. That's an oversimplification, but essentially true. Any changes you make to an entity bean are reflected in the database. The strengths of entity beans are they (often) allow you to do database operations without writing JDBC/SQL code and they give you easy access to the app server's features, such as transactions, security, connection pooling, etc. The weakness of entity beans is the overhead they add to your application. When you are using session beans to access entity beans, you can greatly reduce this overhead by using local interfaces, rather than the standard remote interfaces. Hope that helps!
 
manish basotia
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Greg, but what advantage it has got over simple client server application. means i could have directly used some SQL statement to do "CRUD" Operations.

with Regards
Manish
 
David Harkness
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by manish basotia:
[B]ut what advantage it has got over simple client server application. means i could have directly used some SQL statement to do "CRUD" Operations.
Sun originally intended entity beans to be coarse grained business objects with support for transactions, security and remoting. Since most people writing web software have less stringent requirements, they used them as row-level objects. They suit that purpose, but they're overkill in most situations.

For these and other reasons (complexity and configuration), many people have turned to simpler and more efficient ORM (Object Relational Mapping) tools like Hibernate, JDO, etc. They tend to have more flexibility of mappings without the overhead of transactions and security, which most people handled in the session beans anyway.

As well, we are seeing leight frameworks like Spring replacing session beans and other EJB container services.

P.S. You may find that many people read "urgent" and skip the posting, having the opposite effect you intended.
 
Ellen Zhao
Ranch Hand
Posts: 581
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
get this book if you can: J2EE development without EJB

I'm on chapter 7. Chapter 5 answers manish's question in detail and in depth.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic