Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Interview question on Entity Beans

 
manish ahuja
Ranch Hand
Posts: 312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All
Sorry for this question again. Last time i couldnt get a convincing answer.
Interviewers keep bugging me with this
Why Entity Beans. What is that we cant acheive with SLSB and DAO that we have to resort to an Entity Beans approach.
What does Entity Bean try to acheive. Or Sun has just introduced Entity Beans as a replacement for DAO. What is Entity Beans USP
(Sorry these are not my words but that of the interviewer)

Rgrds
 
Jack Zhou
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is my try.
advanteage:
1: programmer don't have to write db access code.
2:As the container improves, your programmer can improve without
any code change.
3. Entity Bean give a more standard object model which let people to
your new projecd easy to understand.
 
Nicholas Cheung
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Manish,

Why Entity Beans.

It is an Java data object that represents a data record inside the database.

What is that we cant acheive with SLSB and DAO that we have to resort to an Entity Beans approach.

We can have our own data object by selecting it out from the DB via JDBC inside DAO. However, we dont have any additional services provided by the container. For example, an entity bean X is representing a data record Y. The container can request a lock in the database, and for different clients, they have different stubs but point to the same entity object.
If we create such object using JDBC, different clients may have different version of that object, if one updates it, others goes stale. But we cannot make a lock on it, otherwise, no other objects can access this data.

What does Entity Bean try to acheive. Or Sun has just introduced Entity Beans as a replacement for DAO.

Entity bean is trying to make data access more easier, with transaction and security, and so on. It cannot replace DAO because NOT all queries are suitable for using Entity bean.
If the database is fully normalized, you may have a main table that need to join 5-6 tables to get the whole piece of information (like MovieID, DirectorID, ActorID, etc in the main table, and your result requires to display the real name of the movie, director and actors).
In such case, entity bean is not suitable, as the overhead is very large.

What is Entity Beans USP

Sorry, what is USP?
Nick.
 
Vishwa Kumba
Ranch Hand
Posts: 1066
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. Why Entity Beans?
-Entity beans represent business objects in the enterprise. Session beans manage business logic/workflow.
Both are meant for different purposes in an application.

2. What is that we cant acheive with SLSB and DAO that we have to resort to an Entity Beans approach?
-Nothing. It all comes down to good design, modularity, maintainence and portability.


As Jack and Nicholas said,
EJB2.0 - supports EJB-QL, so there is no need to write SQL for CRUD operations.
- supports relationships thru local interfaces.
- good performance, as the containers use highly optimized queries.

3. Sun has just introduced Entity Beans as a replacement for DAO.
- No. DAO does not replace entity beans. DAO is a design pattern, while Entity bean is an EJB, a piece of J2EE technology.
As Nicholas said, you might still use DAOs to retrieve/change your data in the database inside a SLSB bean, based on your
project needs/design.


Originally posted by manish ahuja:
Hi All,
Sorry for this question again. Last time i couldnt get a convincing answer.
Interviewers keep bugging me with this

Manish,
Next time, if you try to post similar questions in the other EJB forum, you are likely to get more answers...
In the interview, what you need is confidence...atleast try to act to be confident. Do not bluff. The world is.. afterall..... a stage full of actors.....

Hope that helps!
 
manish ahuja
Ranch Hand
Posts: 312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Vish
Thanx for your advice.
The answers which i got were the ones which i already know. Being new to ejb(ENTITY BEANS) in particular , i felt i was missing some things.
In interviews,I have been giving the same answers mentioned above but the unconvinced look on the interviewers face does not feel good.
Once is ok but going through the same episode again & again (3 times) made me feel i am really missing something about Entity Beans.
Sorry for the inconvenience caused to you
Rgrds
Manish
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is that we cant acheive with SLSB and DAO that we have to resort to an Entity Beans approach.

In my department, entity beans have been banned due to poor performance. Instead, one can do something like this.
client --> SLSB --> DAO --> DB broker --> DB
The DB broker is a singleton which handles DB access.
ALso, our SQL (cached in a HashMap on startup) contains PreparedStatements. All of this, plus connection pooling of course, gives decent performance on the application which I happen to be developing.
 
Nathaniel Stoddard
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
EJB is more than just a means of persisting objects.
Remember that there are other issues at hand, like transactions, and who knows what else. In addition, there are personnel issues. For example, if all your developers know EJB, why would you have them use any of the other (presumably unfamiliar) solutions available? Developer familiarity is a big part of how well software development projects do, so it must be taken into account.
I'm afraid that questions like this aren't as clear cut as some would like. Just keep rambling about all the different issues -- I'm sure your interviewer will be impressed .
 
Sany Bel
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am new to Java Ranch and also to EJB. I am currently preparing for EJB certification. To answer your question, I think the main advantage of using Entity beans is to keep your object and data in the database in sync. Your bean will always represent the current data in your database. I don't think you can achieve this using DAO's.
 
R.x Lan
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The thing is: OODB systems do well on this topic(EB).
[ March 18, 2004: Message edited by: Rixin Lan ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic